﻿Imports Commander_Wars.Spieletools
Public Class frmScriptWriter
    Const StandardKI As Integer = 3
    Const StandardFond As Integer = 0
    Const StandardFondPS As Integer = 1000
    Const StandardFondPF As Integer = 30000
    Const StandardBauliste As Integer = 3

    Public Shared Sprache As Sprachen = Sprachen.English
    Public Shared Dateiname As String = ""
    Public Shared scDateiname As String = ""
    Public Shared DateinameLandkarte As String = ""
    Public Shared OrdnernameLandkarte As String = ""
    Public Shared LandkartenName As String = ""
    Public Shared ScriptGeladen As Boolean = False
    Public Shared SpielerAnz As Integer = 0
    Public Shared Ini As Boolean = False
    Public Shared SprachKonvIni As New DialogTextSprachKonverter
    Public Shared SprachKonvScript As New DialogTextSprachKonverter
    Public Shared FontFett As Font
    Dim OffsetOben As Integer = 10
    Dim OffsetBreiteZuNachbar As Integer = 10
    Dim Reihenhöhe As Integer = 26

    Dim ParamHöhe As Integer = 26

    'Script Variables:

    Dim scInd As Integer = -1
    Dim scConditionInd As Integer = -1
    Dim scEventInd As Integer = -1
    Public Shared scripte() As objScript = {}

    Dim AktuelleBedingung As objBedingung
    Dim AktuellesEreignis As objEreignis
    Dim AktuellerCOEffekt As KOCustom.Power.PowerScript.Effect

    Dim ZusatzInfos() As ZusatzInfo = {}




    'Controls:
    Dim _numStartGeld() As NumericUpDown = {}
    Dim _numFondspS() As NumericUpDown = {}
    Dim _numFondspF() As NumericUpDown = {}
    Dim _cmbKI() As ComboBox = {}
    Dim _btnFarbe() As ComboBox = {}
    Dim _lblTeam() As ComboBox = {}
    Dim _cmbBauliste() As ComboBox = {}
    Dim _cmbKO1() As ComboBox = {}
    Dim _cmbKO2() As ComboBox = {}
    Dim _cbUnbesiegbar() As CheckBox = {}

    Dim _condParalbl(6) As Label
    Dim _condParanum(6) As NumericUpDown
    Dim _condParacmb(6) As ComboBox
    Dim _EventParalbl(6) As Label
    Dim _EventParanum(6) As NumericUpDown
    Dim _EventParacmb(6) As ComboBox
    Dim _COEffectsParalbl(6) As Label
    Dim _COEffectsParanum(6) As NumericUpDown
    Dim _COEffectsParacmb(6) As ComboBox


    Dim KOCheckboxen As CheckBox()
    Dim Player As New List(Of PlayerInfos)

    Dim CustomCOPowers() As KOCustom.Power = {New KOCustom.Power, New KOCustom.Power, New KOCustom.Power}
    Structure PlayerInfos
        Public KOS1 As String
        Public KOS2 As String
        Public KI As KIGenerellerSuperBau.PrioritätsBau
        Public Sub New(ByVal KOS1 As String, ByVal KOS2 As String)
            KI = New KIGenerellerSuperBau.PrioritätsBau(KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal, KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal, KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal, KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal, KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal, KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal, KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal, 14000, 13000, True)
            Me.KOS1 = KOS1

            Me.KOS2 = KOS2

        End Sub
    End Structure

    'KOs
    Public Shared KOID() As String = {}
    Public Shared KOÜbersetzt() As String = {}
    'Conditions
    Public Shared ConditionsID() As String = {}
    Public Shared ConditionsÜbersetzt() As String = {}
    Public Shared ConditionsTipp() As String = {}
    'Events
    Public Shared EventsID() As String = {}
    Public Shared EventsÜbersetzt() As String = {}
    Public Shared EventsTipp() As String = {}
    'Units
    Public Shared UnitID() As String = {}
    Public Shared UnitÜbersetzt() As String = {}

    Public Shared MissionsstatusID() As String = {"MGewonnen", "MAuswählbar", "MNichtAuswählbar"}
    Public Shared MissionsstatusÜbersetzt() As String = {"Mission Won", "Mission choosable", "Mission not choosable"}

    Public Shared FarbtabellenID() As String = {"Orange.bmp", "Blau.bmp", "Gelb.bmp", "Grün.bmp", "Schwarz.bmp", "Dunkelblau.bmp", "Dunkelbraun.bmp", "DunkelGrün.bmp", "DunkelRosa.bmp", "DunkelSchwarz.bmp", "Gelbbraun.bmp", "Jade.bmp", "Lila.bmp", "Metall.bmp", "OrangeGelb.bmp", "Türkise.bmp", "Violet.bmp"} ', "Neutral.bmp"
    Public Shared FarbtabellenÜbersetzt() As String = {Armeen.OS.ToString, Armeen.BM.ToString, Armeen.YC.ToString, Armeen.GE.ToString, Armeen.BH.ToString, "dark blue", "dark brown", "dark green", "dark pink", "dark black", Armeen.AC.ToString, Armeen.JS.ToString, Armeen.PC.ToString, Armeen.MA.ToString, Armeen.BD.ToString, Armeen.TG.ToString, Armeen.DM.ToString} ', "Neutral.bmp"

    Public Shared ArmeeID() As String = [Enum].GetNames(Armeen.OS.GetType)
    Public Shared ArmeeÜbersetzt() As String = {"Orange Star", "Blue Moon", "Yellow Comet", "Green Earth", "Black Hole", "Amber Coranne", "Jade Sun", "Pinc Cosmos", "Metall Army", "Brown Desert", "Teal Galaxy", "Dark Matter"}

    Public Shared SpezialFähigkID() As String = {"", "Bauen", "Feuerrakete", "TruppenBau", "Explosion", "Reparieren", "Ration", "MoveAndFire"}
    Public Shared SpezialFähigkÜbersetzt() As String = {"-", "can build", "signal rocket", "build air forces", "can explode", "repair", "ration", "move and fire"}

    Public Shared BewegungsartID() As String = {MovementSorts.Fuß.ToString, "ReifenA", "ReifenB", MovementSorts.Ketten.ToString, MovementSorts.Höllium.ToString, MovementSorts.Läufer.ToString, MovementSorts.Helikopter.ToString, MovementSorts.Flugzeug.ToString, MovementSorts.Amphibie.ToString, MovementSorts.Schiff.ToString, MovementSorts.Transport.ToString}
    Public Shared BewegungsartÜbersetzt() As String = {"Foot", "Tires A", "Tires B", "Tread", "Oozium", "Piperunner", "Helicopter", "Plane", MovementSorts.Amphibie.ToString, "Ship", MovementSorts.Transport.ToString}

    Public Shared WaffenID() As String = {"Keine", "Abstandswaffe", "AufklärerMG", "Bazooka", "Boden-Luft-Raketen", "Bomben", "V3-Rakete", "CruiseMissile", "Flak-Gewehr", "FlareMG", "H-Bomben", "InfanterieMG", "JagdpanzerHaubitze", "K-HeliMG", "KampfpanzerHaubitze", "KampfpanzerMG", "Kanone", "Läuferhaubitze", "Luft-Boden-Raketen", "Luftraketen", "MechMG", "Megahaubitze", "MegapanzerMG", "Megakanone", "Omni-Missile", "Panzerfaust", "PanzerKanone", "Raketen", "Scharfschützengewehr", "See-Luft-Raketen", "See-Raketen", "SpäherMG", "Titanhaubitze", "TitanpanzerMG", "Torpedo", "Vulkan-Waffe", "WasserRakete", "Zwillingshaubitze"}
    Public Shared WaffenÜbersetzt() As String = {"-", "Anti-Ship Missile", "Scout MG", "Bazooka", "Land-Air-Rocket", "Bombs", "V3-Rocket", "Cruise Missile", "Flak-Gun", "Flare MG", "H-Bombs", "Infantry MG", "Tank Howitzer", "Copter MG", "Medium Tank Howitzer", "Medium Tank MG", "Canon", "Piperunner Howitzer", "Air-Land-Rockets", "Air-Rockets", "Mech MG", "Mega Howitzer", "Megatank MG", "Mega Canon", "Omni-Missile", "Anti-Tank-Rocket", "Anti-Tank-Canon", "Rockets", "Sniper Rifle", "Sea-Air-Rockets", "Sea-Rockets", "Recon MG", "Neotank Howitzer", "Neotank MG", "Torpedo", "Volcan-Weapon", "Water Rockets", "Gemini Howitzer"}

    Public Shared LandschaftID() As String = {"AUSGETROCKNETESFLUSSBETT", "BAUBRÜCKE", "BERG", "BRÜCKE", "EBENE", "EBENE+SCHROTT", "FELSEN", "FLUSS", "GIPFEL", "KAKTEEN", "KAPUTTEPIPESCHWEIß", "KAPUTTESCHWEIßNAHT", "KIEFERN", "SCHNEE", "RIFF", "PLINESCHWEIß", "PLINEKAPUTT", "PLINE", "PIPESCHWEIß", "PIPELINE", "PIPE", "PFAD", "MAUER", "LUFT", "ZUGBRÜCKE", "WÜSTE+Schrott", "WÜSTE", "WOLKEN", "WALD", "SUMPF", "STRAßENFROST", "STRAßE", "STRAND", "SEE", "SCHWEIßNAHT", "SCHNEE+SCHROTT", "BASIS", "FABRIK", "FESTUNG", "FLIEGENDEFESTUNG", "FLIEGENDESMINIGESCHÜTZ+N", "FLIEGENDESMINIGESCHÜTZ+S", "FLIEGENDESMINIGESCHÜTZ+O", "FLIEGENDESMINIGESCHÜTZ+W", "FLUGHAFEN", "WERFT", "HQ", "KRISTALL", "LABOR", "LASER", "MINE", "MINIGESCHÜTZ+N", "MINIGESCHÜTZ+S", "MINIGESCHÜTZ+O", "MINIGESCHÜTZ+W", "MONOLITH", "OMEGARAKETE", "PIPESTATION", "RADAR", "RAKETENSILO", "RAKETENSILO+RAKETE", "SCHOCKLASER+N", "SCHOCKLASER+S", "SCHOCKLASER+O", "SCHOCKLASER+W", "SCHWARZE GESCHÜTZ+N", "SCHWARZE GESCHÜTZ+S", "SCHWARZE GESCHÜTZ+O", "SCHWARZE GESCHÜTZ+W", "STADT", "TURM", "VULKAN"}
    Public Shared LandschaftÜbersetzt() As String = {"Parched Riverbed", "Construction Bridge", "Mountain", "Bridge", "Plain", "Plain with Junk", "Rock", "River", "Mountain Peak", "Cactuses", "Destroyed Desert Seam", "Destroyed Seam", "Pines", "Snow", "Reef", "Snow Seam", "Destroyed Snow Seam", "Snow Pipe", "Desert Seam", "Pipeline", "Desert Pipeline", "Desert Road", "Wall", "Air", "Drawbridge", "Desert with Junk", "Desert", "Clouds", "Forests", "Swamp", "Snow Road", "Road", "Beach", "Sea", "Seam", "Snow with Junk", "Base", "Factory", "Fortress", "Flying Fortress", "Airminicanon North", "Airminicanon South", "Airminicanon East", "Airminicanon West", "Airport", "Harbour", "HQ", "Crystall", "Labor", "LASER", "Mine", "Minicanon North", "Minicanon South", "Minicanon East", "Minicanon West", "Black Crystall", "Omega Rocket", "Pipestation", "Radar", "Silo", "Silo with Rocket", "Death Ray North", "Death Ray South", "Death Ray East", "Death Ray West", "Black Canon North", "Black Canon South", "Black Canon East", "Black Canon West", "Town", "Tower", "Volcan"}

    'Public Shared EinheitenID() As String = {"ABPZ", "ART", "AUFKLÄRER", "BAUPANZER", "BOMBER", "DREADNAUGHT", "FLAK", "FLARE", "FLTR", MovementSorts.HÖLLIUM.tostring.toupper, "HOVERCRAFT", "HOVERFLAK", "INF", "JGPZ", "JÄGER", "K-HELI", "KPZ", "KANONENBOOT", "KREUZER", "L-BOOT", "LÄUFER", MovementSorts.MECH.tostring.toupper, "MEGAPZ", "MISSILE", "MOTORRAD", "PANZERABWEHRKANONE", "RKW", "SSIEINHEIT", "SCHLFF", "S-BOMBE", "S-BOOT", "SCHWERESHOVERCRAFT", "SPÄHER", "TARNK", "TITANPZ", "T-FLUGZEUG", "T-HELI", "TRITON", "TTL", "TTP", "U-BOOT", "VERSORGUNGSSCHIFF", "WASSERFLUGZEUG", "ZEPPELIN", "ZERSTÖRER", "Gebäude"}
    'Public Shared EinheitenÜbersetzt() As String = {"A-Craft", "Artillery", "Scout", "Construction Tank", "Bomber", "Dreadnaught", "Anti-Air", "Flare", "Carrier", "Oozium", "Hovercraft", "Hovercraft Anti-Air", "Infantry", "Tank", "Fighter", "Battle Copter", "Medium Tank", "Canonboat", "Cruiser", "L-Boat", "Piperunner", MovementSorts.Mech.tostring, "Megatank", "Missile", "Bike", "Anti-Tank", "Rockets", "Sniper", "Battleship", "Black Bomb", "Black Boat", "Heavy Hovercraft", "Recon", "Stealth", "Neotank", "Transport Plane", "T-Copter", "Triton", "TTL", "APC", "Sub", "Transportship", "Seaplane", "Zeppelin", "Destroyer", "Building"}

    'ROUTINES

    ''' <summary>
    ''' Erschafft eine komplett neue Ini. Also wie wenn eine leere Ini geladen worden wäre.
    ''' </summary>
    ''' <remarks></remarks>
    Sub NeuIni()
        setDefaultIni(True)
        Dateiname = ""
    End Sub

    ''' <summary>
    ''' Erschafft ein komplett neues Script. Also wie wenn aus einer leeren Datei geladen worden wäre
    ''' </summary>
    ''' <remarks></remarks>
    Sub NeuScript()
        Array.Resize(scripte, 0)
        SprachKonvScript = New DialogTextSprachKonverter
        lbScripts.Items.Clear()
        scInd = -1
        scDateiname = ""
        ScriptGeladen = True
    End Sub

    ''' <summary>
    ''' Erschafft eine komplett neue Landkarten ini. Also wie wenn aus einer leeren Datei geladen worden wäre
    ''' </summary>
    ''' <remarks></remarks>
    Sub NeuLandkarte()
        DateinameLandkarte = ""
        OrdnernameLandkarte = ""
        CheckLandkarteOrdnerFarbe()
        setDefaultLandkarte()
    End Sub



    Sub LoadScript()
        If My.Computer.FileSystem.FileExists(scDateiname) Then
            lbScripts.Items.Clear()
            lbScripts.SelectedIndex = -1
            ReDim scripte(-1) 'Erstmal alles löschen..

            SprachKonvScript = New DialogTextSprachKonverter

            Dim ErsteZeile As Boolean = True
            Dim strR As New IO.StreamReader(scDateiname, System.Text.Encoding.Default)
            While Not strR.EndOfStream
                Dim z As String = strR.ReadLine
                z = z.Trim
                If z = "" Then Continue While

                If ErsteZeile Then 'Naja eigentlich eher erste Zeile, in der irgendwelche informationen enthalten sind..
                    ErsteZeile = False
                    If z.StartsWith("###") Then
                        'Es wird sowieso ein neues Script gleich gemacht, warte einfach mal die nächsten paar codezeilen ab...
                    ElseIf z.StartsWith("'") Then
                        NewScript(z.Remove(0, 1).Trim)
                        Continue While
                    Else
                        NewScript()
                    End If
                End If
                If z.StartsWith("'") Then Continue While

                If z.ToLower.StartsWith("###".ToLower) Then
                    NewScript(z.Remove(0, 3).Trim, True)
                    Continue While
                End If


                ' B E D I N G U N G E N :

                If z.ToLower.StartsWith("Tag:".ToLower) Then
                    z = z.Remove(0, 4)
                    Dim s() As String = z.Split("|")
                    addScriptBedingung(Bedingungsarten.TagGleich, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("Tag>".ToLower) Then
                    z = z.Remove(0, 4)
                    Dim s() As String = z.Split("|")
                    addScriptBedingung(Bedingungsarten.TagGrößer, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("Tag<".ToLower) Then
                    z = z.Remove(0, 4)
                    Dim s() As String = z.Split("|")
                    addScriptBedingung(Bedingungsarten.TagKleiner, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("Tag*".ToLower) Then
                    z = z.Remove(0, 4)
                    Dim s() As String = z.Split("|")
                    addScriptBedingung(Bedingungsarten.TagMal, s)
                    Continue While
                End If
                If z.StartsWith("Besetzt:") Then
                    z = z.Remove(0, 8)
                    Dim s() As String = z.Split("|")
                    addScriptBedingung(Bedingungsarten.Besetzt, s)
                    Continue While
                End If
                If z.StartsWith("Sieg:") Then
                    z = z.Remove(0, 5)
                    addScriptBedingung(Bedingungsarten.Sieg, New String() {z.ToUpper})
                    Continue While
                End If
                If z.StartsWith("Feuerladung:") Then
                    z = z.Remove(0, 12)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.Feuerladung, s)
                    Continue While
                End If
                If z.StartsWith("NachXZügenImmer:") Then
                    z = z.Remove(0, 16)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.TagMalImmer, s)
                    Continue While
                End If
                If z.StartsWith("LandkartenZustand:") Then
                    z = z.Remove(0, 18)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.LandkartenZustand, s)
                    Continue While
                End If
                If z.StartsWith("CountLandkarteZustand:") Then
                    z = z.Remove(0, 22)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.CountLandkarteZustand, s)
                    Continue While
                End If
                If z.StartsWith("GebäudeZerstört:") Then
                    z = z.Remove(0, 16)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.GebäudeZerstört, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("spielerbesiegt:") Then
                    z = z.Remove(0, 15)
                    addScriptBedingung(Bedingungsarten.SpielerBesiegt, New String() {z})
                    Continue While
                End If
                If z.ToLower.StartsWith("inbereich:") Then
                    z = z.Remove(0, 10)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.InBereich, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("einheitzerstört:") Then
                    z = z.Remove(0, 16)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.EinheitZerstört, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("feldleer:") Then
                    z = z.Remove(0, 9)
                    Dim s As String() = z.Split("|")
                    addScriptBedingung(Bedingungsarten.FeldLeer, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("zufall:") Then
                    z = z.Remove(0, 7)
                    addScriptBedingung(Bedingungsarten.Zufall, New String() {z})
                    Continue While
                End If
                If z.ToLower.StartsWith("variablegleich:") Then
                    z = z.Remove(0, z.IndexOf(":") + 1)
                    addScriptBedingung(Bedingungsarten.Zufall, New String() {z})
                    Continue While
                End If
                If z.ToLower.StartsWith("variablekleiner:") Then
                    z = z.Remove(0, z.IndexOf(":") + 1)
                    addScriptBedingung(Bedingungsarten.Zufall, New String() {z})
                    Continue While
                End If
                If z.ToLower.StartsWith("variablegrößer:") Then
                    z = z.Remove(0, z.IndexOf(":") + 1)
                    addScriptBedingung(Bedingungsarten.Zufall, New String() {z})
                    Continue While
                End If
                If z.ToLower.StartsWith("variablegrößergleich:") Then
                    z = z.Remove(0, z.IndexOf(":") + 1)
                    addScriptBedingung(Bedingungsarten.Zufall, New String() {z})
                    Continue While
                End If


                ' E R E I G N I S S E : 

                If z.StartsWith("Dialog:") Then
                    z = z.Remove(0, 7)
                    Dim s() As String = z.Split("|")
                    Dim Chat As String = ""
                    For i = 3 To s.Length - 2
                        Chat += s(i) + "|"
                    Next
                    Chat += s(s.Length - 1)
                    addScriptEreignis(Ereignisarten.Dialog, New String() {s(0), s(1), s(2), "", "", Chat})
                    Continue While
                End If
                If z.ToLower.StartsWith("Dialog2:".ToLower) Then
                    Dim s() As String = z.Remove(0, z.IndexOf(":") + 1).Split("|")
                    For iii = 6 To s.Length - 1
                        s(5) += "|" + s(iii)
                    Next
                    'Dim de As String = ""
                    'Dim en As String = ""
                    'If s(5).ToLower.Trim.StartsWith("%Language%".ToLower.Trim) Then
                    '    Dim TextID As Integer = s(5).Split("%")(2)
                    '    en = SprachKonvScript.getText("English", TextID)
                    '    de = SprachKonvScript.getText("Deutsch", TextID)
                    '    If en = "" Then en = de
                    '    If de = "" Then de = en
                    'Else
                    '    'Naja wenn ich nur einen Text habe, dann ist der lieber im Englischen wie im Deutschen gleich, als wenn da jetzt in dem einen nix steht. (Dann doch lieber Fremdsprache)
                    '    en = s(5)
                    '    de = s(5)
                    'End If
                    addScriptEreignis(Ereignisarten.Dialog, New String() {s(0), s(1), s(2), s(3), s(4), s(5)}) ' de, en})
                    Continue While
                End If
                If z.StartsWith("%") Then
                    'hm.. eine Sprach...
                    Dim s() As String = z.Split("%")
                    SprachKonvScript.AddEintrag(s(1), s(3), s(2))
                    Continue While
                End If
                If z.StartsWith("EinheitE:") Then
                    z = z.Remove(0, 9)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.EinheitenSpawn, s)
                    Continue While
                End If
                If z.StartsWith("SetKP:") Then
                    z = z.Remove(0, 6)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.SetKP, s)
                    Continue While
                End If
                If z.StartsWith("SetKO:") Then
                    z = z.Remove(0, 6)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.SetKO, s)
                    Continue While
                End If
                If z.StartsWith("Schadenswelle|") Then
                    Dim s() As String = z.Remove(0, 14).Split("|")
                    addScriptEreignis(Ereignisarten.Schadenswelle, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("landkarte|") Then
                    Dim s() As String = z.Remove(0, 10).Split("|")
                    addScriptEreignis(Ereignisarten.landkarte, s)
                    Continue While
                End If
                If z.StartsWith("Gewonnen:") Then
                    z = z.Remove(0, 9)
                    addScriptEreignis(Ereignisarten.Gewonnen, New String() {z.ToUpper})
                    Continue While
                End If
                If z.StartsWith("SetFeuerladung:") Then
                    z = z.Remove(0, 15)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.SetFeuerladung, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("addwarteeinheit:") Then
                    z = z.Remove(0, 16)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.AddWarteEinheit, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("removeblockierteeinheit:") Then
                    z = z.Remove(0, 24)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.RemoveBlockierteEinheit, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("setfabrikfonds:") Then
                    z = z.Remove(0, 15)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.setFabrikFonds, s)
                    Continue While
                End If
                If z.ToLower.StartsWith("neutralergebäudeangriff:") Then
                    z = z.Remove(0, 24)
                    Dim s() As String = z.Split("|")
                    addScriptEreignis(Ereignisarten.NeutralerGebäudeAngriff, s)
                    Continue While
                End If


                'Sonstiges:
                If mnuShowInvalidScriptLines.Checked Then
                    MsgBox("Invalid script line:" + Environment.NewLine + z, MsgBoxStyle.Exclamation, "Invalid code")
                End If

            End While
            strR.Dispose()
            'vielleicht gibt es ja leere Scripts, dann kann ich die Ja rausschmeissen.

            ScriptGeladen = True
        Else
            NeuScript()
            If txtScriptName.Text.Trim = "" Then
                MsgBox("Please create a new script, or just enter a scriptname in the ini-menu at the textbox ""Scriptname:"". This Script can be created automatically after that.", MsgBoxStyle.Exclamation, "no script found")
            Else
                If MsgBox("the Script: """ + txtScriptName.Text + """ is not found. Do you like to create it?", MsgBoxStyle.YesNo, "new Script") = MsgBoxResult.Yes Then
                    scDateiname = My.Settings.Resourcenpfad + "Scripts\" + txtScriptName.Text.Trim + ".script"
                    txtScriptName.BackColor = Color.LimeGreen
                End If
            End If
        End If
    End Sub
    Sub LoadScriptOpen()
        OpenFileDialog1.Title = "Open Script"
        OpenFileDialog1.DefaultExt = ".script"
        OpenFileDialog1.Filter = "Script-Files|*.script|All Files|*.*"
        If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "Scripts\") Then OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "Scripts\"
        If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then
            scDateiname = OpenFileDialog1.FileName
            ScriptGeladen = False
            LoadScript()
        End If
    End Sub
    Sub LoadIni()
        OpenFileDialog1.Title = "Open Ini"
        OpenFileDialog1.DefaultExt = ".ini"
        OpenFileDialog1.Filter = "Ini-Files|*.ini|All Files|*.*"
        If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "Karten\") Then OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "Karten\"

        If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then
            If OpenFileDialog1.FileName.Trim.ToLower.EndsWith("\landkarte.ini") Then
                'Oh oh, das ist zwar auch ne Ini, aber das ist trotzdem etwas anderes!
                LoadIniLandkarte(OpenFileDialog1.FileName)
                Exit Sub
            End If

            Dateiname = OpenFileDialog1.FileName
            ' Dateiname = OpenFileDialog1.FileName
            'Standard-Einstellungen
            setDefaultIni(False)
            'txtKartenname.Text = ""
            'txtNächsteKarte.Text = ""
            'txtScriptName.Text = ""
            pSpielerdaten.Controls.Clear()
            Dim Spieler As Integer = 0
            Dim _StartGeld() As Integer = {}
            Dim _FondspS() As Integer = {}
            Dim _FondspF() As Integer = {}
            Dim _KI() As Integer = {}
            Dim _Farbe() As String = {}
            Dim _Team() As Char = {}
            Dim _Bauliste() As Integer = {}
            Dim _KO1() As String = {}
            Dim _KO2() As String = {}
            Dim _Unbesiegbar() As Boolean = {}
            Player = New List(Of PlayerInfos)

            Dim AlleBauliste As Integer = -1

            Dim strR As New IO.StreamReader(OpenFileDialog1.FileName, System.Text.Encoding.Default)
            While Not strR.EndOfStream
                Dim z As String = strR.ReadLine
                z = z.Trim
                If z = "" Then Continue While 'Leerzeilen ausblenden
                If z.StartsWith("'") Then Continue While 'Kommentare ausblenden

                If z.ToLower.StartsWith("gamemode:") Then
                    cmbIniGameModus.SelectedIndex = z.Remove(0, z.IndexOf(":") + 1)
                    Continue While
                End If


                If z.ToLower = "SofortStart=1".ToLower Then cbSofortStart.Checked = True
                If z.ToLower = "SofortStart=0".ToLower Then cbSofortStart.Checked = False

                If z.ToLower = "ZufallsWetter=1".ToLower Then cbZufallswetter.Checked = True
                If z.ToLower = "ZufallsWetter=0".ToLower Then cbZufallswetter.Checked = False

                If z.ToLower.StartsWith("startwetter=") Then
                    cbStartwetter.SelectedIndex = z.Split("=")(1)
                End If

                If z.ToLower = "Kriegsnebel=0".ToLower Then cmbKriegsnebel.SelectedItem = cmbKriegsnebel.Items(0)
                If z.ToLower = "Kriegsnebel=1".ToLower Then cmbKriegsnebel.SelectedItem = cmbKriegsnebel.Items(1)
                If z.ToLower = "Kriegsnebel=2".ToLower Then cmbKriegsnebel.SelectedItem = cmbKriegsnebel.Items(2)

                If z.ToLower = "Luftschlacht=0".ToLower Then cbLuftschlacht.Checked = False
                If z.ToLower = "Luftschlacht=1".ToLower Then cbLuftschlacht.Checked = True

                If z.ToLower = "Promotion=0".ToLower Then cbPromotion.Checked = False
                If z.ToLower = "Promotion=1".ToLower Then cbPromotion.Checked = True

                If z.ToLower.StartsWith("name:") Then txtKartenname.Text = z.Remove(0, 5)
                If z.ToLower.StartsWith("NächsteKarte:".ToLower) Then txtNächsteKarte.Text = z.Remove(0, 13)
                If z.ToLower.StartsWith("Script:".ToLower) Then txtScriptName.Text = z.Remove(0, 7)
                If z.ToLower.StartsWith("Desc:".ToLower) Then setKartenBeschreibung(z.Remove(0, 5))

                If z.ToLower.StartsWith("Team|".ToLower) Or z.ToLower.StartsWith("KI|".ToLower) Or z.ToLower.StartsWith("Farbe|".ToLower) Or z.ToLower.StartsWith("StartGeld|".ToLower) Or z.ToLower.StartsWith("unbesiegbar|") Or z.ToLower.StartsWith("Bauliste|".ToLower) Or z.ToLower.StartsWith("FondsPS|".ToLower) Or z.ToLower.StartsWith("FondsPF|".ToLower) Or z.ToLower.StartsWith("KO|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    If CInt(s(1)) > Spieler Then
                        Spieler = CInt(s(1))
                        If Spieler < Player.Count Then
                            Player.RemoveRange(Spieler - 1, Player.Count - Spieler)
                        ElseIf Spieler > Player.Count Then
                            For I = Player.Count To Spieler - 1
                                Player.Add(New PlayerInfos("ANDY", "-"))
                            Next
                        End If
                        Array.Resize(_Bauliste, Spieler)
                        Array.Resize(_Farbe, Spieler)
                        Array.Resize(_FondspF, Spieler)
                        Array.Resize(_FondspS, Spieler)
                        Array.Resize(_KI, Spieler)
                        Array.Resize(_KO1, Spieler)
                        Array.Resize(_KO2, Spieler)
                        Array.Resize(_StartGeld, Spieler)
                        Array.Resize(_Team, Spieler)
                        Array.Resize(_Unbesiegbar, Spieler)

                        _Bauliste(Spieler - 1) = StandardBauliste
                        _Farbe(Spieler - 1) = getStandardFarbe(Spieler)
                        _FondspF(Spieler - 1) = StandardFondPF
                        _FondspS(Spieler - 1) = StandardFondPS
                        _KI(Spieler - 1) = StandardKI
                        _KO1(Spieler - 1) = "Andy"
                        _KO2(Spieler - 1) = "-"
                        _StartGeld(Spieler - 1) = StandardFond
                        _Team(Spieler - 1) = getStandardTeam(Spieler)
                        _Unbesiegbar(Spieler - 1) = False
                    End If
                End If
                If z.ToLower.StartsWith("Team|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    _Team(s(1) - 1) = s(2)
                End If
                If z.ToLower.StartsWith("KI|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    _KI(s(1) - 1) = s(2)
                End If
                If z.ToLower.StartsWith("Farbe|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    _Farbe(s(1) - 1) = s(2)
                End If
                If z.ToLower.StartsWith("StartGeld|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    _StartGeld(s(1) - 1) = s(2)
                End If
                If z.ToLower.StartsWith("unbesiegbar|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    _Unbesiegbar(s(1) - 1) = True
                End If
                If z.ToLower.StartsWith("Bauliste|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    If s(1) = 0 Then
                        AlleBauliste = s(2)
                    Else
                        _Bauliste(s(1) - 1) = s(2)
                    End If
                End If
                If z.ToLower.StartsWith("FondsPS|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    _FondspS(s(1) - 1) = s(2)
                End If
                If z.ToLower.StartsWith("FondsPF|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    _FondspF(s(1) - 1) = s(2)
                End If
                If z.ToLower.StartsWith("KO|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    If s(2) = "0" Then
                        _KO1(s(1) - 1) = s(3)
                        Dim P As PlayerInfos = Player(s(1) - 1)
                        P.KOS1 = s(3)
                        Player(s(1) - 1) = P
                    Else
                        _KO2(s(1) - 1) = s(3)
                        Dim P As PlayerInfos = Player(s(1) - 1)
                        P.KOS2 = s(3)
                        Player(s(1) - 1) = P
                    End If
                End If

                If z.ToLower.StartsWith("bauprioritäten|") Then
                    Dim s As String() = z.Split("|")
                    Dim P As PlayerInfos = Player(s(1) - 1)
                    P.KI = New KIGenerellerSuperBau.PrioritätsBau(s(2), s(3), s(4), s(5), s(6), s(7), s(8), s(9), s(10), False)
                    Player(s(1) - 1) = P
                End If

                If z.ToLower.StartsWith("siegbedingungen|".ToLower) Then
                    Select Case z.Split("|")(1).ToLower
                        Case "aus", "off"
                            cbSiegHQ.Checked = False
                            cbSiegEinheiten.Checked = False
                        Case "hq sieg", "hqsieg"
                            cbSiegHQ.Checked = True
                        Case "einheiten sieg", "einheitensieg"
                            cbSiegEinheiten.Checked = True
                        Case "besetzung sieg", "besetzungsieg"
                            If z.Split("|")(2) > 0 Then
                                cbSiegEinnehmen.Checked = True
                                numSiegEinnehmen.Value = z.Split("|")(2)
                            Else
                                cbSiegEinnehmen.Checked = False
                            End If
                        Case "besetzung zeit", "besetzungzeit"
                            If z.Split("|")(2) > 0 Then
                                cbSiegZeit.Checked = True
                                numSiegZeit.Value = z.Split("|")(2)
                            Else
                                cbSiegZeit.Checked = False
                            End If
                    End Select
                End If

                If z.ToLower.StartsWith("Dialog:".ToLower) Then
                    Dim s() As String = z.Remove(0, z.IndexOf(":") + 1).Split("|")
                    'If s(3).ToLower.Trim.StartsWith("%Language%".ToLower) Then
                    'Else
                    For iii = 4 To s.Length - 1
                        s(3) += "|" + s(iii)
                    Next
                    AddRowDialog(dgvIniDialog, SprachKonvIni, s(0), s(1), s(2), s(3))
                    'End If
                End If
                If z.ToLower.StartsWith("Dialog2:".ToLower) Then
                    Dim s() As String = z.Remove(0, z.IndexOf(":") + 1).Split("|")
                    'If s(3).ToLower.Trim.StartsWith("%Language%".ToLower) Then
                    'Else
                    For iii = 6 To s.Length - 1
                        s(5) += "|" + s(iii)
                    Next
                    AddRowDialog(dgvIniDialog, SprachKonvIni, s(0), s(1), s(2), s(3), s(4), s(5))
                    'End If
                End If
                If z.StartsWith("%") Then
                    'hm.. eine Sprach...
                    Dim s() As String = z.Split("%")
                    SprachKonvIni.AddEintrag(s(1), s(3), s(2))
                End If
            End While
            strR.Dispose()

            If AlleBauliste >= 0 Then
                For i = 0 To Spieler - 1
                    _Bauliste(i) = AlleBauliste
                Next
            End If

            Me.Text = "Commander Wars - Script writer:   " + txtKartenname.Text

            SpielerAnz = Spieler
            Array.Resize(_cmbBauliste, SpielerAnz)
            Array.Resize(_btnFarbe, SpielerAnz)
            Array.Resize(_numFondspF, SpielerAnz)
            Array.Resize(_numFondspS, SpielerAnz)
            Array.Resize(_cmbKI, SpielerAnz)
            Array.Resize(_cmbKO1, SpielerAnz)
            Array.Resize(_cmbKO2, SpielerAnz)
            Array.Resize(_numStartGeld, SpielerAnz)
            Array.Resize(_lblTeam, SpielerAnz)
            Array.Resize(_cbUnbesiegbar, SpielerAnz)



            'Die schöne Spielerstatistik anzeigen...
            For i = 0 To Spieler - 1
                addSpielerInSpielerinfos(i, _Team(i), _KI(i), _Farbe(i), _StartGeld(i), _FondspS(i), _FondspF(i), _Unbesiegbar(i), _Bauliste(i), getKOString(_KO1(i)), getKOString(_KO2(i)))
            Next

            If tabControl.SelectedTab.Name = tabScript.Name Then
                tabControl_SelectedIndexChanged(Nothing, Nothing)
            End If

            numSpieler.Value = Spieler
            numSelectedPlayer.Value = 2
            numSelectedPlayer.Value = 1
        End If
    End Sub
    Sub LoadIniLandkarte(ByVal Filename As String)
        If My.Computer.FileSystem.FileExists(Filename) Then
            setDefaultLandkarte()

            Dim Mind As Integer = 0
            DateinameLandkarte = Filename
            OrdnernameLandkarte = Filename.Remove(Filename.LastIndexOf("\"))
            CheckLandkarteOrdnerFarbe()
            Dim strR As New IO.StreamReader(Filename, System.Text.Encoding.Default)
            While Not strR.EndOfStream
                Dim z As String = strR.ReadLine
                z = z.Trim
                If z = "" Then Continue While
                If z.Contains("//") Then
                    z = z.Remove(z.IndexOf("//"))
                End If
                z = z.Trim

                If z.ToLower = "Komprimiert=1".ToLower Then
                    cbLandkarteKomprimiert.Checked = True
                End If
                If z.ToLower.StartsWith("Hintergrund:".ToLower) Then
                    txtLandkarteHintergrund.Text = z.Remove(0, z.IndexOf(":") + 1)
                End If
                If z.ToLower.StartsWith("Name:".ToLower) Then
                    txtLandkarteName.Text = z.Remove(0, z.IndexOf(":") + 1)
                End If
                If z.ToLower.StartsWith("GameMode:".ToLower) Then
                    cmbLandkarteGameMode.SelectedIndex = z.Split(":")(1)
                End If
                If z.ToLower.StartsWith("BlockierteEinheit:".ToLower) Then
                    Dim s() As String = z.Remove(0, z.IndexOf(":") + 1).Split("|")
                    Dim ind As Integer = dgvLandkarteBlockierteEinheiten.Rows.Add()
                    Dim Feld As DataGridViewComboBoxCell = dgvLandkarteBlockierteEinheiten.Rows.Item(ind).Cells.Item(0)
                    Feld.Value = getArmeString(s(1))
                    Feld = dgvLandkarteBlockierteEinheiten.Rows.Item(ind).Cells.Item(1)
                    Feld.Value = getUnitString(s(0))
                End If
                If z.ToLower.StartsWith("Mission|".ToLower) Then
                    Dim s() As String = z.Split("|")
                    Dim Spalte As DataGridViewComboBoxColumn = dgvLandkarteMissionen.Columns(4)
                    Dim sInd As Integer = s(6)
                    If Not sInd = 1 Then sInd = 0
                    Dim RInd As Integer = dgvLandkarteMissionen.Rows.Add(New Object() {Mind, s(1), s(2), "", Spalte.Items(sInd)})
                    dgvLandkarteMissionen.Rows(RInd).Cells(3).Style.BackColor = Color.FromArgb(255, s(3), s(4), s(5))
                    Mind += 1
                End If
            End While
            strR.Dispose()
        Else
            LoadIniLandkarteOpen()
        End If
    End Sub
    Sub LoadIniLandkarteOpen()
        OpenFileDialog1.Title = "Open worldmap Ini"
        OpenFileDialog1.DefaultExt = "Landkarte.ini"
        OpenFileDialog1.Filter = "World maps|Landkarte.ini|All Files|*.*"
        If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "Karten\") Then OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "Karten\"

        If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then
            LoadIniLandkarte(OpenFileDialog1.FileName)
        End If
    End Sub

    Sub LoadCustomUnit()
        OpenFileDialog1.Title = "Open Custom Unit"
        OpenFileDialog1.DefaultExt = ".ent"
        OpenFileDialog1.Filter = "Custom Units|*.ent"
        OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\Unit\"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If My.Computer.FileSystem.FileExists(OpenFileDialog1.FileName) Then
                LoadCustomUnit(OpenFileDialog1.FileName)
            End If
        End If
    End Sub
    Sub LoadCustomUnit(ByVal Datei As String)
        Using R As New IO.StreamReader(Datei, System.Text.Encoding.Default)
            While Not R.EndOfStream
                Dim Z As String = R.ReadLine.Trim
                If Z.StartsWith("'") Then Continue While
                If Z.ToLower.StartsWith("einheitenname:") Then
                    txtCuName.Text = Z.Remove(0, 14)
                    Continue While
                End If
                If Z.ToLower.StartsWith("einheitenid:") Then
                    txtCuID.Text = Z.Remove(0, 12)
                    Continue While
                End If
                If Z.ToLower.StartsWith("sprit:") Then
                    numCuTreibstoff.Value = Z.Remove(0, 6)
                    Continue While
                End If
                If Z.ToLower.StartsWith("tarnen:") Then
                    cbCuTarnen.Checked = Z.Remove(0, 7)
                    Continue While
                End If
                If Z.ToLower.StartsWith("besetzen:") Then
                    cbCuBesetzen.Checked = Z.Remove(0, 9)
                    Continue While
                End If
                If Z.ToLower.StartsWith("treibstoffverbrauch:") Then
                    numCuTreibstoffStartRunde.Value = Z.Remove(0, 20)
                    Continue While
                End If
                If Z.ToLower.StartsWith("kosten:") Then
                    numCuKosten.Value = Z.Remove(0, 7)
                    Continue While
                End If
                If Z.ToLower.StartsWith("fähigkeit:") Then
                    cmbCuFähigkeit.Text = getFähigkString(Z.Remove(0, 10))
                    Continue While
                End If
                If Z.ToLower.StartsWith("bewegungspunkte:") Then
                    numCuBewegungspunkte.Value = Z.Remove(0, 16)
                    Continue While
                End If
                If Z.ToLower.StartsWith("bewegungsart:") Then
                    cmbCuBewgungsart.Text = getBewegungsString(Z.Remove(0, 13))
                    Continue While
                End If
                If Z.ToLower.StartsWith("sicht:") Then
                    numCuSicht.Value = Z.Remove(0, 6)
                    Continue While
                End If
                If Z.ToLower.StartsWith("munition:") Then
                    numCuMunition.Value = Z.Remove(0, 9)
                    Continue While
                End If
                If Z.ToLower.StartsWith("waffe1:") Then
                    cmbCuWaffe1.Text = getWaffenString(Z.Remove(0, 7))
                    Continue While
                End If
                If Z.ToLower.StartsWith("waffe2:") Then
                    cmbCuWaffe2.Text = getWaffenString(Z.Remove(0, 7))
                    Continue While
                End If
                If Z.ToLower.StartsWith("ladung:") Then
                    numCuTransportKapazität.Value = Z.Remove(0, 7)
                    Continue While
                End If
                If Z.ToLower.StartsWith("geladeneeinheiten:") Then
                    Dim GeladeneEinheitenIDs As String() = Z.Remove(0, 18).Split("|")
                    For I = 0 To dgvCuGeladeneEinheiten.Rows.Count - 2
                        If GeladeneEinheitenIDs.Contains(getEinheitenID(dgvCuGeladeneEinheiten.Rows(I).Cells(SpalteCuGeladeneEinheiten.Index).Value)) Then
                            dgvCuGeladeneEinheiten(SpalteCuGeladeneEinheiten.Index, I).Style.BackColor = Color.Lime
                            dgvCuGeladeneEinheiten(SpalteCuGeladeneEinheiten.Index, I).Style.SelectionBackColor = Color.Lime
                        Else
                            dgvCuGeladeneEinheiten(SpalteCuGeladeneEinheiten.Index, I).Style.BackColor = Color.Red
                            dgvCuGeladeneEinheiten(SpalteCuGeladeneEinheiten.Index, I).Style.SelectionBackColor = Color.Red
                        End If

                    Next
                    'Neue Einheiten hinzufügen
                    For I = 0 To GeladeneEinheitenIDs.Length - 1
                        For I2 = 0 To dgvCuGeladeneEinheiten.Rows.Count - 1
                            If getEinheitenID(dgvCuGeladeneEinheiten(SpalteCuGeladeneEinheiten.Index, I).Value) = GeladeneEinheitenIDs(I) Then
                                Exit For
                            End If
                            If I2 = dgvCuGeladeneEinheiten.Rows.Count - 1 Then
                                Dim Zelle As DataGridViewTextBoxCell = dgvCuGeladeneEinheiten.Rows(dgvCuGeladeneEinheiten.Rows.Add()).Cells(SpalteCuGeladeneEinheiten.Index)
                                Zelle.Value = GeladeneEinheitenIDs(I)
                                Zelle.Style.BackColor = Color.Lime
                                Zelle.Style.SelectionForeColor = Color.Black
                                Zelle.Style.SelectionBackColor = Color.Lime
                            End If
                        Next
                    Next

                    Continue While
                End If
                If Z.ToLower.StartsWith("entladungsuntergrund:") Then
                    Dim EntladungsUntergrund As String() = Z.Remove(0, 21).Split("|")
                    For I = 0 To dgvCuLadungsUntergrund.Rows.Count - 1
                        If EntladungsUntergrund.Contains(getLandschaftID(dgvCuLadungsUntergrund(SpalteCuTerrainUntergrund.Index, I).Value)) Then
                            dgvCuLadungsUntergrund(SpalteCuTerrainUntergrund.Index, I).Style.BackColor = Color.Lime
                            dgvCuLadungsUntergrund(SpalteCuTerrainUntergrund.Index, I).Style.SelectionBackColor = Color.Lime
                        Else
                            dgvCuLadungsUntergrund(SpalteCuTerrainUntergrund.Index, I).Style.BackColor = Color.Red
                            dgvCuLadungsUntergrund(SpalteCuTerrainUntergrund.Index, I).Style.SelectionBackColor = Color.Red
                        End If
                    Next

                    Continue While
                End If
                If Z.ToLower.StartsWith("minimalreichweite:") Then
                    numCuReichweiteMin.Value = Z.Remove(0, 18)
                    Continue While
                End If
                If Z.ToLower.StartsWith("maximalereichweite:") Then
                    numCuReichweiteMax.Value = Z.Remove(0, 19)
                    Continue While
                End If
                If Z.ToLower.StartsWith("explosion:") Then
                    cmbCuExplosion.Text = Z.Remove(0, 10)
                    Continue While
                End If
                If Z.ToLower.StartsWith("verteidigungstabelle:") Then
                    While Not R.EndOfStream
                        Z = R.ReadLine.Trim
                        If Z.StartsWith("'") Then Continue While
                        If Z.ToLower.StartsWith("tabellenende") Then Exit While
                        Dim Name As String = Z.Split(":")(0)
                        Dim Wert As Integer = Z.Split(":")(1)
                        For I = 0 To dgvCuDefence.Rows.Count - 2
                            If getEinheitenID(dgvCuDefence.Rows(I).Cells(SpalteCuDefenceUnit.Index).Value) = Name Then
                                dgvCuDefence.Rows(I).Cells(SpalteCuDefenceWert.Index).Value = Wert
                            ElseIf I = dgvCuDefence.Rows.Count - 2 Then
                                Dim Zelle As DataGridViewTextBoxCell = dgvCuDefence.Rows(dgvCuDefence.Rows.Add()).Cells(SpalteCuDefenceUnit.Index)
                                Zelle.Value = Name
                                Zelle = dgvCuDefence.Rows(Zelle.RowIndex).Cells(SpalteCuDefenceWert.Index)
                                Zelle.Value = Wert
                            End If
                        Next
                    End While
                    Continue While
                End If
                If Z.ToLower.StartsWith("produktionsorte:") Then
                    Dim ProduktionsOrte As String() = Z.Remove(0, 16).Split("|")
                    For I = 0 To dgvCuProd.Rows.Count - 1
                        If ProduktionsOrte.Contains(getLandschaftID(dgvCuProd.Rows(I).Cells(SpalteCuBauenErlauben.Index).Value)) Then
                            dgvCuProd(SpalteCuBauenErlauben.Index, I).Style.BackColor = Color.Lime
                            dgvCuProd(SpalteCuBauenErlauben.Index, I).Style.SelectionBackColor = Color.Lime
                        Else
                            dgvCuProd(SpalteCuBauenErlauben.Index, I).Style.BackColor = Color.Red
                            dgvCuProd(SpalteCuBauenErlauben.Index, I).Style.SelectionBackColor = Color.Red
                        End If
                    Next
                    Continue While
                End If
            End While
        End Using
    End Sub
    Sub LoadCustomBewegungsart()
        OpenFileDialog1.Title = "Open Custom Movement"
        OpenFileDialog1.DefaultExt = ".bew"
        OpenFileDialog1.Filter = "Custom Units|*.bew"
        OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\Movement\"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If My.Computer.FileSystem.FileExists(OpenFileDialog1.FileName) Then
                LoadCustomBewegungsart(OpenFileDialog1.FileName)
            End If
        End If
    End Sub
    Sub LoadCustomBewegungsart(ByVal File As String)
        Using StrR As New IO.StreamReader(File, System.Text.Encoding.Default)
            While Not StrR.EndOfStream
                Dim Z As String = StrR.ReadLine.Trim
                If Z.StartsWith("'") Then Continue While
                If Z.ToLower.StartsWith("bewegungstabelle:") Then
                    Dim Tabellenname As String = Z.Remove(0, 17)
                    tbCuBewegungsartname.Text = Tabellenname.Split("+")(0)
                    Dim Spalte As Integer = 0
                    Select Case Tabellenname.Split("+")(1)
                        Case "Regen"
                            Spalte = SpalteCuRegen.Index
                        Case "Sandsturm"
                            Spalte = SpalteCuSandsturm.Index
                        Case "Schnee"
                            Spalte = SpalteCuSnow.Index
                        Case Else
                            Spalte = SpalteCuSonne.Index
                    End Select
                    'Erst ein Reset
                    For I = 0 To dgvCuBewegungstabelle.Rows.Count - 1
                        dgvCuBewegungstabelle.Rows(I).Cells(Spalte).Value = "-1"
                    Next
                    While Not StrR.EndOfStream
                        Dim Z1 As String() = StrR.ReadLine.Trim.Split(":")
                        If Z1(0).ToLower.StartsWith("tabellenende") Then Exit While
                        For I = 0 To dgvCuBewegungstabelle.Rows.Count - 1
                            If getLandschaftID(dgvCuBewegungstabelle.Rows(I).Cells(SpalteCuName.Index).Value) = Z1(0) Then
                                dgvCuBewegungstabelle.Rows(I).Cells(Spalte).Value = Z1(1)
                            End If
                        Next
                    End While
                End If
            End While
        End Using
    End Sub
    Sub LoadCustomWeapon()
        OpenFileDialog1.Title = "Open Custom Weapon"
        OpenFileDialog1.DefaultExt = ".waf"
        OpenFileDialog1.Filter = "Custom Units|*.waf"
        OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\Weapon\"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If My.Computer.FileSystem.FileExists(OpenFileDialog1.FileName) Then
                LoadCustomWeapon(OpenFileDialog1.FileName)
            End If
        End If
    End Sub
    Sub LoadCustomWeapon(ByVal File As String)
        Using StrR As New IO.StreamReader(File, System.Text.Encoding.Default)
            While Not StrR.EndOfStream
                Dim Z As String = StrR.ReadLine.Trim
                If Z.StartsWith("'") Then Continue While
                If Z.ToLower.StartsWith("tabellenende") Then Exit While
                If Z.ToLower.StartsWith("angriffstabelle:") Then
                    txtCuWaffenname.Text = Z.Split(":")(1)
                    While Not StrR.EndOfStream
                        Dim Z1() As String = StrR.ReadLine.Trim.Split(":")
                        If Z1(0).ToLower.StartsWith("tabellenende") Then Exit While
                        For I = 0 To dgvCuWaffe.Rows.Count - 2
                            If getEinheitenID(dgvCuWaffe.Rows(I).Cells(SpalteCuWaffeOpfer.Index).Value) = Z1(0) Then
                                dgvCuWaffe.Rows(I).Cells(SpalteCuDamage.Index).Value = Z1(1)
                            ElseIf I = dgvCuWaffe.Rows.Count - 2 Then
                                Dim Zelle As DataGridViewTextBoxCell = dgvCuWaffe.Rows(dgvCuWaffe.Rows.Add()).Cells(SpalteCuWaffeOpfer.Index)
                                Zelle.Value = Z1(0)
                                Zelle = dgvCuWaffe.Rows(Zelle.RowIndex).Cells(SpalteCuDamage.Index)
                                Zelle.Value = Z1(1)
                            End If
                        Next
                    End While
                End If
            End While
        End Using
    End Sub

    Sub LoadKarte(ByVal Kartenpfad As String)
        Hauptmenü.KarteDefaultLaden(Kartenpfad)
    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="Spieler">1=erster Spieler; 2=zweiter Spieler</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function getStandardFarbe(ByVal Spieler As Integer) As String
        Spieler -= 1
        If Spieler < 0 Then Spieler = 0
        If Spieler > FarbtabellenID.Length - 1 Then Spieler = FarbtabellenID.Length - 1

        Return FarbtabellenID(Spieler)
    End Function
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="Spieler">1=erster Spieler; 2=zweiter Spieler</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function getStandardTeam(ByVal Spieler As Integer) As String
        If Spieler < 1 Then Spieler = 1
        If Spieler > 26 Then Spieler = 26
        Dim b As Byte = 64 + Spieler
        Return System.Text.ASCIIEncoding.ASCII.GetString(New Byte() {b})
    End Function


    Sub Save()
        SaveIni()
        SaveScript()
    End Sub
    Sub SpeichernUnter()
        SpeichernUnterIni()
        SpeichernUnterScript()
    End Sub

    Sub SaveIni()
        If Dateiname.Trim = "" Then
            SpeichernUnterIni()
            Exit Sub
        End If

        If Not Eingabenprüfen() Then Exit Sub
        If Not DialogPrüfen(dgvIniDialog) Then
            MsgBox("The Dialogue seems to be wrong! Make sure, that you didn't forgot some cells.")
            Exit Sub
        End If

        Dim StrW As New IO.StreamWriter(Dateiname, False, System.Text.Encoding.Default)
        If Dateiname.ToLower.EndsWith(".ini") Then
            'INI 
            StrW.WriteLine("'Mode in which this map is played:")
            StrW.WriteLine("gamemode:" + cmbIniGameModus.SelectedIndex.ToString)
            StrW.WriteLine("'Name of the map:")
            If Not txtKartenname.Text.Trim = "" Then StrW.WriteLine("Name:" + txtKartenname.Text.Trim)
            StrW.WriteLine("")
            StrW.WriteLine("'Description of the map:")
            If Not getKartenBeschreibung() = "" Then StrW.WriteLine("Desc:" + getKartenBeschreibung())
            StrW.WriteLine("")
            StrW.WriteLine("'the name of the script. the ending can be with "".script"" or without, that doesn't matter")
            If Not txtScriptName.Text.Trim = "" Then StrW.WriteLine("Script:" + txtScriptName.Text.Trim)
            StrW.WriteLine("")
            StrW.WriteLine("'the name of the next map, if you win this one. In Campaigns with world maps, this shouldn't be used!")
            If Not txtNächsteKarte.Text.Trim = "" Then StrW.WriteLine("NächsteKarte:" + txtNächsteKarte.Text.Trim)
            StrW.WriteLine("")
            StrW.WriteLine("")

            StrW.WriteLine("'if ""SofortStart=1"", the game will start instantly. Alternatively =0, then you will be able to change the starting conditions")
            If cbSofortStart.Checked Then
                StrW.WriteLine("SofortStart=1")
            Else
                StrW.WriteLine("SofortStart=0")
            End If
            StrW.WriteLine("")
            StrW.WriteLine("'Decides wether the air battle is active")
            If cbLuftschlacht.Checked Then
                StrW.WriteLine("Luftschlacht=1")
            Else
                StrW.WriteLine("Luftschlacht=0")
            End If
            StrW.WriteLine("")
            StrW.WriteLine("'Decides if you can select more CO's out of one Army!")
            StrW.WriteLine("koproarmee|" + cbEinKOProArmee.Checked.ToString)
            StrW.WriteLine("")
            StrW.WriteLine("'the kind of Fog, which is used in the game.    0 = No Fog; 1 = Mist of War; 2 = Fog of War")
            StrW.WriteLine("Kriegsnebel=" + cmbKriegsnebel.SelectedIndex.ToString)
            StrW.WriteLine("")
            StrW.WriteLine("'Decides wether the weather is choosen by Random")
            If cbZufallswetter.Checked Then
                StrW.WriteLine("ZufallsWetter=1")
            Else
                StrW.WriteLine("ZufallsWetter=0")
            End If
            StrW.WriteLine("")
            StrW.WriteLine("'Decides with which weather the game will start")
            StrW.WriteLine("Startwetter=" + cbStartwetter.SelectedIndex.ToString)
            StrW.WriteLine("")
            StrW.WriteLine("'if the unit can be promoted.")
            If cbPromotion.Checked Then
                StrW.WriteLine("Promotion=1")
            Else
                StrW.WriteLine("Promotion=0")
            End If
            StrW.WriteLine("")
            StrW.WriteLine("'if you are allowed to build as much units as you want.")
            If cbBauStopp.Checked Then
                StrW.WriteLine("Baublockade=1")
            Else
                StrW.WriteLine("Baublockade=0")
            End If
            StrW.WriteLine("")
            StrW.WriteLine("'How expanisve units get the more units you have of this.")
            StrW.WriteLine("teuerungsrate=" + nudTeurungsrate.Value.ToString)

            StrW.WriteLine("")
            StrW.WriteLine("")
            StrW.WriteLine("")
            StrW.WriteLine("' P L A Y E R   I N F O R M A T I O N :")
            StrW.WriteLine("")
            For i = 0 To SpielerAnz - 1
                StrW.WriteLine("")
                StrW.WriteLine("'Player " + (i + 1).ToString + ":")
                StrW.WriteLine("Team|" + (i + 1).ToString + "|" + _lblTeam(i).Text)
                StrW.WriteLine("KI|" + (i + 1).ToString + "|" + _cmbKI(i).SelectedIndex.ToString)
                StrW.WriteLine("StartGeld|" + (i + 1).ToString + "|" + _numStartGeld(i).Value.ToString)
                StrW.WriteLine("FondsPS|" + (i + 1).ToString + "|" + _numFondspS(i).Value.ToString)
                StrW.WriteLine("FondsPF|" + (i + 1).ToString + "|" + _numFondspF(i).Value.ToString)
                StrW.WriteLine("Farbe|" + (i + 1).ToString + "|" + getFarbtabellenID(_btnFarbe(i).SelectedItem))

                Dim K As String = Player(i).KOS1
                If K.Split("|").Length <= 0 Then
                    K = getKOID(_cmbKO1(i).SelectedItem) + "|" + K
                Else
                    K = getKOID(_cmbKO1(i).SelectedItem)
                End If
                StrW.WriteLine("KO|" + (i + 1).ToString + "|0|" + K)
                K = Player(i).KOS2
                If K.Split("|").Length <= 0 Then
                    K = getKOID(_cmbKO2(i).SelectedItem) + "|" + K
                Else
                    K = getKOID(_cmbKO2(i).SelectedItem)
                End If
                StrW.WriteLine("KO|" + (i + 1).ToString + "|1|" + K)
                StrW.WriteLine("Bauliste|" + (i + 1).ToString + "|" + _cmbBauliste(i).SelectedIndex.ToString)
                If _cbUnbesiegbar(i).Checked Then StrW.WriteLine("Unbesiegbar|" + (i + 1).ToString)
                If Not Player(i).KI.AutoGenerated Then StrW.WriteLine("BauPrioritäten|" + (i + 1).ToString + "|" + Player(i).KI.ToString)
            Next
            StrW.WriteLine("")
            StrW.WriteLine("")
            StrW.WriteLine("'Conditions to Win:")
            StrW.WriteLine("siegbedingungen|off")
            If cbSiegEinheiten.Checked Then StrW.WriteLine("siegbedingungen|Einheiten Sieg")
            If cbSiegHQ.Checked Then StrW.WriteLine("siegbedingungen|HQ Sieg")
            If cbSiegEinnehmen.Checked Then StrW.WriteLine("siegbedingungen|besetzung sieg|" + numSiegEinnehmen.Value.ToString)
            If cbSiegZeit.Checked Then StrW.WriteLine("siegbedingungen|besetzung zeit|" + numSiegZeit.Value.ToString)

            StrW.WriteLine("")
            StrW.WriteLine("")
            StrW.WriteLine("")
            StrW.WriteLine("")
            StrW.WriteLine("")
            StrW.WriteLine("'DIALOGUE SYSTEM: You can use this just in a world map mission!")
            StrW.WriteLine("")
            'Die alten Sachen sind vergessen. Es kommt nur auf die neuen an!
            For i = 0 To dgvIniDialog.Rows.Count - 2
                Dim KOID As String
                Dim Spieler As Integer
                Dim Gesichtsausdruck As Integer
                Dim TextDe As String
                Dim TextEn As String
                Dim TextID As Integer
                Dim Musik As String
                Dim Bild As String
                KOID = getKOID(dgvIniDialog.Rows(i).Cells(SpalteIniDialogKO.Index).Value)
                Spieler = getArrayInd(SpalteIniDialogFarbe.Items, dgvIniDialog.Rows(i).Cells(SpalteIniDialogFarbe.Index).Value) + 1
                Gesichtsausdruck = getArrayInd(SpalteIniDialogGesichtsausdruck.Items, dgvIniDialog.Rows(i).Cells(SpalteIniDialogGesichtsausdruck.Index).Value)
                TextDe = dgvIniDialog.Rows(i).Cells(SpalteIniDialogTextDeutsch.Index).Value
                TextEn = dgvIniDialog.Rows(i).Cells(SpalteIniDialogTextEnglish.Index).Value
                Musik = dgvIniDialog.Rows(i).Cells(SpalteIniDialogMusik.Index).Value
                Bild = dgvIniDialog.Rows(i).Cells(SpalteIniDialogBild.Index).Value
                TextID = i + 1

                If TextDe IsNot Nothing Then TextDe = TextDe.Trim
                If TextEn IsNot Nothing Then TextEn = TextEn.Trim
                If TextDe = "" Then TextDe = TextEn
                If TextEn = "" Then TextEn = TextDe
                StrW.WriteLine("%English%" + TextID.ToString + "%" + TextEn)
                StrW.WriteLine("%Deutsch%" + TextID.ToString + "%" + TextDe)
                StrW.WriteLine("Dialog2:" + KOID + "|" + Spieler.ToString + "|" + Gesichtsausdruck.ToString + "|" + Musik + "|" + Bild + "|%Language%" + TextID.ToString + "%") 'ANDY|1|0|Musik|Bild|Die Kampagne beginnt.
            Next


        ElseIf Dateiname.ToLower.EndsWith(".script") Then
            'SCRIPT

        Else
            '???
            MsgBox("What's that File???" + Environment.NewLine + Dateiname + Environment.NewLine + "There are ini-Files and script-Files, but I don't know, what that File is!" + Environment.NewLine + "if that's no joke, please change the Filename!", MsgBoxStyle.Critical, "Unknown File")
        End If
        StrW.Flush()
        StrW.Dispose()
    End Sub
    Sub SaveScript()
        If scDateiname.Trim = "" Then
            SpeichernUnterScript()
            Exit Sub
        End If

        If scDateiname.ToLower.EndsWith(".script") Then
            Dim StrW As New IO.StreamWriter(scDateiname, False, System.Text.Encoding.Default)
            'bevor die ganzen Scripte kommen womöglich mit vielen Dialogen, sollten wir zuerst die ganzen Sprachübersetzungen aufschreiben.
            SprachKonvScript.WriteKonverter(StrW)

            Dim erstesScript As Boolean = True
            For Each Sc In scripte

                If erstesScript Then
                    StrW.WriteLine("'" + Sc.Desc)
                    erstesScript = False
                Else
                    StrW.WriteLine("###" + Sc.Desc) 'Der Standardmäßige anfang, von jedem Script!
                End If

                StrW.WriteLine("")
                StrW.WriteLine("'Conditions:")
                For Each Cond In Sc.Bedingungen
                    StrW.WriteLine(Cond.Output)
                Next
                StrW.WriteLine("")
                StrW.WriteLine("'Events:")
                For Each Ev In Sc.Ereignisse
                    StrW.WriteLine(Ev.Output)
                Next
                StrW.WriteLine("")
                StrW.WriteLine("")
                StrW.WriteLine("")
            Next

            StrW.Flush()
            StrW.Close()
        Else
            MsgBox("I just save Scripts as "".script""-Files!", MsgBoxStyle.Critical, "wrong ending")
        End If
        CheckTextScriptFarbe()
    End Sub
    Sub SaveLandkarte()
        If DateinameLandkarte.Trim = "" Then
            SpeichernUnterLandkarte()
            Exit Sub
        End If

        'sichergehen, dass alle Eingaben gültig sind!

        For i = 0 To dgvLandkarteBlockierteEinheiten.Rows.Count - 2 'Die letzte ist ja die die "neu angelegt wird"
            If dgvLandkarteBlockierteEinheiten.Rows(i).Cells(0).Value Is Nothing Or dgvLandkarteBlockierteEinheiten.Rows(i).Cells(1).Value Is Nothing Then
                MsgBox("please enter Units and armys in the table with the blocked units!" + Environment.NewLine + "you can delete a line, by clicking on the left of the line and pressing delete!", MsgBoxStyle.Critical, "invalid input!")
                Exit Sub
            End If
        Next
        For i = 0 To dgvLandkarteMissionen.Rows.Count - 2 'Die letzte ist ja die die "neu angelegt wird"
            If dgvLandkarteMissionen.Rows(i).Cells(1).Value Is Nothing Or dgvLandkarteMissionen.Rows(i).Cells(2).Value Is Nothing Or dgvLandkarteMissionen.Rows(i).Cells(4).Value Is Nothing Or dgvLandkarteMissionen.Rows(i).Cells(3).Style.BackColor.ToArgb = Color.FromArgb(0, 0, 0, 0).ToArgb Then
                ' If dgvLandkarteMissionen.Rows(i).Cells(3).Style.BackColor.ToArgb = Color.FromArgb(0, 0, 0, 0).ToArgb Then
                MsgBox("please make input in each cell!" + Environment.NewLine + "you can delete a line, by clicking on the left of the line and pressing delete!", MsgBoxStyle.Critical, "invalid input!")
                Exit Sub
                ' End If
            End If
        Next

        Dim StrW As New IO.StreamWriter(DateinameLandkarte, False, System.Text.Encoding.Default)

        '        If cbLandkarteKomprimiert.Checked Then StrW.WriteLine("Komprimiert=1")
        If Not txtLandkarteHintergrund.Text.Trim = "" Then StrW.WriteLine("Hintergrund:" + txtLandkarteHintergrund.Text.Trim)
        If cmbLandkarteGameMode.SelectedIndex >= 0 Then StrW.WriteLine("GameMode:" + (cmbLandkarteGameMode.SelectedIndex).ToString)
        If Not txtLandkarteName.Text.Trim = "" Then StrW.WriteLine("Name:" + txtLandkarteName.Text.Trim)

        For i = 0 To dgvLandkarteBlockierteEinheiten.Rows.Count - 2
            StrW.WriteLine("BlockierteEinheit:" + getUnitID(dgvLandkarteBlockierteEinheiten.Rows(i).Cells(1).Value) + "|" + getArmeeID(dgvLandkarteBlockierteEinheiten.Rows(i).Cells(0).Value)) 'TITANPZ|OS
        Next
        For i = 0 To dgvLandkarteMissionen.Rows.Count - 2
            Dim Zustand As Integer
            If dgvLandkarteMissionen.Rows(i).Cells(4).Value = "choosable" Then Zustand = 1 Else Zustand = 0
            StrW.WriteLine("Mission|" + dgvLandkarteMissionen.Rows(i).Cells(1).Value + "|" + dgvLandkarteMissionen.Rows(i).Cells(2).Value + "|" + dgvLandkarteMissionen.Rows(i).Cells(3).Style.BackColor.R.ToString + "|" + dgvLandkarteMissionen.Rows(i).Cells(3).Style.BackColor.G.ToString + "|" + dgvLandkarteMissionen.Rows(i).Cells(3).Style.BackColor.B.ToString + "|" + Zustand.ToString) 'Mission|AW2OS1|Säuberung|255|155|155|1|49|249|76|270
        Next


        StrW.Flush()
        StrW.Close()
    End Sub

    Sub SaveCustomEinheit(ByVal Pfad As String)
        'Normall die Einheit speichern
        Dim MovementSort As String = getBewegungskID(cmbCuBewgungsart.Text)
        Dim Waffe1 As String = getWaffenID(cmbCuWaffe1.Text)
        Dim Waffe2 As String = getWaffenID(cmbCuWaffe2.Text)
        If numCuReichweiteMax.Value < numCuReichweiteMin.Value Then
            numCuReichweiteMax.Value = numCuReichweiteMin.Value
        End If
        Using StrW As New IO.StreamWriter(Pfad, False, System.Text.Encoding.Default)
            StrW.WriteLine("einheitenname:" + txtCuName.Text)
            StrW.WriteLine("einheitenid:" + txtCuID.Text.ToUpper)
            StrW.WriteLine("sprit:" + numCuTreibstoff.Value.ToString)
            StrW.WriteLine("tarnen:" + cbCuTarnen.Checked.ToString)
            StrW.WriteLine("besetzen:" + cbCuBesetzen.Checked.ToString)
            StrW.WriteLine("treibstoffverbrauch:" + numCuTreibstoffStartRunde.Value.ToString)
            StrW.WriteLine("kosten:" + numCuKosten.Value.ToString)
            StrW.WriteLine("fähigkeit:" + getFähigkID(cmbCuFähigkeit.SelectedItem))
            StrW.WriteLine("bewegungspunkte:" + numCuBewegungspunkte.Value.ToString)
            StrW.WriteLine("bewegungsart:" + MovementSort)
            StrW.WriteLine("sicht:" + numCuSicht.Value.ToString)
            StrW.WriteLine("munition:" + numCuMunition.Value.ToString)
            StrW.WriteLine("waffe1:" + Waffe1)
            StrW.WriteLine("waffe2:" + Waffe2)
            StrW.WriteLine("ladung:" + numCuTransportKapazität.Value.ToString)
            If numCuTransportKapazität.Value > 0 Then 'Eine kleine Optimierung.
                StrW.WriteLine("geladeneeinheiten:" + getGeladeneEinheiten())
                StrW.WriteLine("entladungsuntergrund:" + getEntladungsUntergrund())
            End If
            StrW.WriteLine("verteidigungstabelle:CustomUnit")
            For I = 0 To dgvCuDefence.Rows.Count - 2
                Dim Name As String = dgvCuDefence.Rows(I).Cells(SpalteCuDefenceUnit.Index).Value
                Dim Wert As Integer = dgvCuDefence.Rows(I).Cells(SpalteCuDefenceWert.Index).Value
                If Wert >= 0 Then
                    StrW.WriteLine(Name + ":" + Wert.ToString)
                End If
            Next
            StrW.WriteLine("Tabellenende")
            StrW.WriteLine("minimalreichweite:" + numCuReichweiteMin.Value.ToString)
            StrW.WriteLine("maximalereichweite:" + numCuReichweiteMax.Value.ToString)
            StrW.WriteLine("explosion:" + getExplosionID(cmbCuExplosion.SelectedItem))
            StrW.WriteLine("produktionsorte:" + getProduktionsGebäude())
        End Using
        CheckTextCuIDFarbe()
    End Sub
    Sub SaveCustomBewegungsart(ByVal Pfad As String)
        Using StrW As New IO.StreamWriter(Pfad, False, System.Text.Encoding.Default)
            For I = 0 To 3
                Dim Column As Integer = 0
                Select Case I
                    Case 1
                        Column = SpalteCuRegen.Index
                        StrW.WriteLine("Bewegungstabelle:" + tbCuBewegungsartname.Text + "+Regen")
                    Case 2
                        Column = SpalteCuSandsturm.Index
                        StrW.WriteLine("Bewegungstabelle:" + tbCuBewegungsartname.Text + "+Sandsturm")
                    Case 3
                        Column = SpalteCuSnow.Index
                        StrW.WriteLine("Bewegungstabelle:" + tbCuBewegungsartname.Text + "+Schnee")
                    Case Else
                        Column = SpalteCuSonne.Index
                        StrW.WriteLine("Bewegungstabelle:" + tbCuBewegungsartname.Text + "+Sonne")
                End Select
                For I2 = 0 To dgvCuBewegungstabelle.Rows.Count - 1
                    StrW.WriteLine(getLandschaftID(dgvCuBewegungstabelle.Rows(I2).Cells(SpalteCuName.Index).Value.ToString) + ":" + dgvCuBewegungstabelle.Rows(I2).Cells(Column).Value.ToString)
                Next
                StrW.WriteLine("Tabellenende")
            Next
        End Using
    End Sub
    Sub SaveCustomWeapon(ByVal File As String)
        Using StrW As New IO.StreamWriter(File, False, System.Text.Encoding.Default)
            StrW.WriteLine("Angriffstabelle:" + txtCuWaffenname.Text)
            For I = 0 To dgvCuWaffe.Rows.Count - 2
                Dim Wert As Integer = dgvCuWaffe.Rows(I).Cells(SpalteCuDamage.Index).Value
                Dim Name As String = getEinheitenID(dgvCuWaffe.Rows(I).Cells(SpalteCuWaffeOpfer.Index).Value)
                If Name = "Building" Then Name = "Gebäude"
                If Wert >= 0 Then
                    StrW.WriteLine(Name + ":" + Wert.ToString)
                End If
            Next
            StrW.WriteLine("Tabellenende")
        End Using
    End Sub

    Sub SpeichernUnterIni()
        SaveFileDialog1.FilterIndex = 1
        If SaveFileDialog1.ShowDialog = DialogResult.OK Then
            Dateiname = SaveFileDialog1.FileName
            SaveIni()
        End If
    End Sub
    Sub SpeichernUnterScript()
        SaveFileDialog1.FilterIndex = 2
        If SaveFileDialog1.ShowDialog = DialogResult.OK Then
            scDateiname = SaveFileDialog1.FileName
            SaveScript()
        End If
    End Sub
    Sub SpeichernUnterLandkarte()
        SaveFileDialog1.Title = "Save world map"
        SaveFileDialog1.Filter = "World map|Landkarte.ini"
        SaveFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "Karten\"
        SaveFileDialog1.FilterIndex = 3
        If SaveFileDialog1.ShowDialog = DialogResult.OK Then
            DateinameLandkarte = SaveFileDialog1.FileName
            SaveLandkarte()
        End If
    End Sub

    Sub ResourcesFestlegen()
        MsgBox("please browse to the ""Resources""-Folder of Commander Wars!", MsgBoxStyle.Information, "Select Resources")
        FolderBrowserDialog1.SelectedPath = My.Settings.Resourcenpfad
        If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
            If FolderBrowserDialog1.SelectedPath.EndsWith("Resources") Then
                My.Settings.Resourcenpfad = FolderBrowserDialog1.SelectedPath
                My.Settings.Save()
            Else
                MsgBox("You have to select the Resources Folder of Commander Wars!", MsgBoxStyle.Critical, "Error!")
            End If
        End If
    End Sub
    Sub Sprachupdate()
        Sprachconverter.LoadLanguage()
        Dim File As String
        Dim strR As IO.StreamReader

        'Noch die Bedingungen
        File = My.Settings.Resourcenpfad + "Script-Writer" + "\Conditions_" + Sprache.ToString + ".txt"
        If My.Computer.FileSystem.FileExists(File) Then
            Array.Resize(ConditionsID, 0)
            Array.Resize(ConditionsÜbersetzt, 0)
            Array.Resize(ConditionsTipp, 0)
            strR = New IO.StreamReader(File, System.Text.Encoding.Default)
            While Not strR.EndOfStream
                Dim z As String = strR.ReadLine
                z = z.Trim
                If z = "" Then Continue While
                If z.StartsWith("'") Then
                    If ConditionsTipp.Length > 0 Then
                        ConditionsTipp(ConditionsTipp.Length - 1) = z.Remove(0, 1)
                    End If
                    Continue While
                End If
                'Ich gehe einfach mal von einer gültigen Datei aus..
                Array.Resize(ConditionsID, ConditionsID.Length + 1)
                Array.Resize(ConditionsÜbersetzt, ConditionsÜbersetzt.Length + 1)
                Array.Resize(ConditionsTipp, ConditionsTipp.Length + 1)
                ConditionsID(ConditionsID.Length - 1) = z.Remove(z.IndexOf("="))
                ConditionsÜbersetzt(ConditionsÜbersetzt.Length - 1) = z.Remove(0, z.IndexOf("=") + 1)
                ConditionsTipp(ConditionsTipp.Length - 1) = "" 'Der Tipp ist nichts. evtl wird er später mit etwas gefüllt
            End While
            strR.Dispose()

            cmbScriptConditionArt.Items.Clear()
            For i = 0 To ConditionsÜbersetzt.Length - 1
                cmbScriptConditionArt.Items.Add(ConditionsÜbersetzt(i))
            Next
        Else
            MsgBox("the file is missing! (Condition)" + Environment.NewLine + "please make sure, that both files (Conditions/Events) of your language is in the Folder, where the executable file is!", MsgBoxStyle.Critical, "missing File")
        End If
        'Noch die Events
        File = My.Settings.Resourcenpfad + "Script-Writer" + "\Events_" + Sprache.ToString + ".txt"
        If My.Computer.FileSystem.FileExists(File) Then
            Array.Resize(EventsID, 0)
            Array.Resize(EventsÜbersetzt, 0)
            Array.Resize(EventsTipp, 0)
            strR = New IO.StreamReader(File, System.Text.Encoding.Default)
            While Not strR.EndOfStream
                Dim z As String = strR.ReadLine
                z = z.Trim
                If z = "" Then Continue While

                If z.StartsWith("'") Then
                    If EventsTipp.Length > 0 Then
                        EventsTipp(EventsTipp.Length - 1) = z.Remove(0, 1)
                    End If
                    Continue While
                End If

                'Ich gehe einfach mal von einer gültigen Datei aus..
                Array.Resize(EventsID, EventsID.Length + 1)
                Array.Resize(EventsÜbersetzt, EventsÜbersetzt.Length + 1)
                Array.Resize(EventsTipp, EventsTipp.Length + 1)
                EventsID(EventsID.Length - 1) = z.Remove(z.IndexOf("="))
                EventsÜbersetzt(EventsÜbersetzt.Length - 1) = z.Remove(0, z.IndexOf("=") + 1)
                EventsTipp(EventsTipp.Length - 1) = "" 'Der Tipp ist nichts. evtl wird er später mit etwas gefüllt
            End While
            strR.Dispose()

            cmbScriptEventArt.Items.Clear()
            For i = 0 To EventsÜbersetzt.Length - 1
                cmbScriptEventArt.Items.Add(EventsÜbersetzt(i))
            Next
        Else
            MsgBox("the file is missing! (Event)" + Environment.NewLine + "please make sure, that both files (Conditions/Events) of your language is in the Folder, where the executable file is!", MsgBoxStyle.Critical, "missing File")
        End If

        'Die Sprache scheint gültig zu sein, dann können wir sie uns ja auch für nächstes mal merken..
        My.Settings.Sprache = Sprache
        My.Settings.Save()

        mnuSpracheDeutsch.Checked = False
        mnuSpracheEnglisch.Checked = False
        Select Case Sprache
            Case Sprachen.Deutsch
                mnuSpracheDeutsch.Checked = True
            Case Sprachen.English
                mnuSpracheEnglisch.Checked = True
        End Select


        'Alle Einheiten laden.
        ObjektLadeklasse.AlleEinheitenLaden()
        Objektverwalter.GebäudeTextur.LoadAlleGebäude()
        Array.Resize(UnitID, Objektverwalter.AlleEinheiten.Length)
        Array.Resize(UnitÜbersetzt, Objektverwalter.AlleEinheiten.Length)
        For i = 0 To UnitID.Length - 1
            UnitID(i) = Objektverwalter.AlleEinheiten(i).EinheitenID
            UnitÜbersetzt(i) = Sprachconverter.Translate(Objektverwalter.AlleEinheiten(i).Einheit.Einheitenname)
        Next
        'Alle KO's laden
        Dim KOS() As Commander_Wars.Objektverwalter.KO = {}
        ObjektLadeklasse.KOLaden(KOS, True)

        Array.Resize(KOID, KOS.Length)
        Array.Resize(KOÜbersetzt, KOS.Length)
        KOID(0) = "-"
        KOÜbersetzt(0) = "-"
        For i = 1 To KOID.Length - 1
            KOID(i) = KOS(i - 1).KOID
            KOÜbersetzt(i) = Sprachconverter.Translate(KOS(i - 1).KOBeschreibung.Name)
        Next

        'Bei den KOs können (Offizier) mehrere KOs gleich übersetzt werden.
        'Ich denke das beste müsste sein, wenn wir in dem Fall einfach noch die ID hinterherstelle.
        For i = 0 To KOÜbersetzt.Length - 2
            Dim iVer As Boolean = False
            For k = i + 1 To KOÜbersetzt.Length - 1
                If KOÜbersetzt(i).ToLower.Trim = KOÜbersetzt(k).ToLower.Trim Then
                    KOÜbersetzt(k) += "_" + KOID(k)
                    iVer = True
                End If
            Next
            If iVer Then
                KOÜbersetzt(i) += "_" + KOID(i)
            End If
        Next
    End Sub

    Sub ScriptIndChanged()
        If scInd < 0 Then
            txtScriptBeschreibung.Text = ""
            Exit Sub
        End If

        scEventInd = -1
        scConditionInd = -1

        'gültig:
        txtScriptBeschreibung.Text = lbScripts.Items(scInd)

        'Conditions:
        lbScriptCondition.Items.Clear()
        For Each Cond In scripte(scInd).Bedingungen
            lbScriptCondition.Items.Add(getConditionString(Cond.Bedingungsart.ToString))
        Next
        'Events:
        lbScriptEvent.Items.Clear()
        For Each Ev In scripte(scInd).Ereignisse
            lbScriptEvent.Items.Add(getEventString(Ev.Ereignisart.ToString))
        Next

        'cmbScriptConditionArt_SelectedIndexChanged(Nothing, Nothing)
        'cmbScriptEventArt_SelectedIndexChanged(Nothing, Nothing)
    End Sub
    Sub ScriptConditionsIndChanged()

        If scConditionInd < 0 Then
            cmbScriptConditionArt.SelectedIndex = 0
            Exit Sub
        End If
        'gültig:
        cmbScriptConditionArt.SelectedItem = lbScriptCondition.Items(scConditionInd)

        'Dim s1 As String = getConditionID(cmbScriptConditionArt.SelectedItem).ToLower
        'Dim s2 As String = Bedingungsarten.TagGleich.ToString


        cmbScriptConditionArt_SelectedIndexChanged(Nothing, Nothing)
    End Sub
    Sub ScriptEventsIndChanged()


        If scEventInd < 0 Then
            cmbScriptEventArt.SelectedIndex = 0
            Exit Sub
        End If
        'gültig:
        cmbScriptEventArt.SelectedItem = lbScriptEvent.Items(scEventInd)

        cmbScriptEventArt_SelectedIndexChanged(Nothing, Nothing)
    End Sub

    Sub SaveCustomCO()
        'CO Description speichern.
        Using strR As New IO.StreamWriter("C:\Programmierung\Commander Wars\Programm\Commander Wars\Advance Wars-Der wahre Feind\Resources\!Custom\CO\CO Desc\" + txtCustomCOID.Text + ".desc", False)
            strR.WriteLine("Name:" + txtCustomCOName.Text)
            strR.WriteLine("Fein:" + txtCustomCOHit.Text)
            strR.WriteLine("Nein:" + txtCustomCOMiss.Text)
            strR.WriteLine("Gaben:" + txtCustomCOPName.Text + "|" + txtCustomCOSCOPName.Text)
            strR.WriteLine("Beschreibung:" + txtCustomCOInfo.Text)
            strR.WriteLine("Stil:" + txtCustomCOStyle.Text)
            strR.WriteLine("Gabebeschreibung:" + txtCustomCOCOP.Text)
            strR.WriteLine("Spezialgabebeschreibung:" + txtCustomCOSCOP.Text)
            strR.WriteLine("Gabesätze:" + txtCustomCOCOPText1.Text + "|" + txtCustomCOCOPText2.Text + "|" + txtCustomCOCOPText3.Text + "|" + txtCustomCOCOPText4.Text + "|" + txtCustomCOCOPText5.Text)
            strR.WriteLine("Siegsätze:" + txtCustomCOWinText1.Text + "|" + txtCustomCOWinText2.Text)
            strR.WriteLine("Tauschsätze:" + txtCustomCOChange1.Text + "|" + txtCustomCOChange2.Text)
            strR.WriteLine("Gabekosten:" + nudCustomCOCOPCost.Value.ToString)
            strR.WriteLine("Spezialgabekosten:" + nudCustomCOSCOPCOST.Value.ToString)
            Dim Synergien As String = ""
            Dim Doppelgabenamen As String = ""
            Dim Doppelgabesätze As String = ""
            Dim KONamen As String = ""
            Dim KOIDS As New List(Of String)
            For I = 0 To dgvTagPowers.Rows.Count - 2
                If I = dgvTagPowers.Rows.Count - 2 Then
                    If Not KOIDS.Contains(dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value) Then
                        Synergien += dgvTagPowers.Rows(I).Cells(dgvCCustomCOSynergie.Index).Value
                        KONamen += dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value
                        Doppelgabenamen += dgvTagPowers.Rows(I).Cells(dgvCCustomCOTagPowerName.Index).Value
                        KOIDS.Add(dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value)
                    End If
                    Dim D1 As String = dgvTagPowers.Rows(I).Cells(dgvCCustomCOText1.Index).Value
                    Dim D2 As String = dgvTagPowers.Rows(I).Cells(dgvCCustomCOSecondSentence.Index).Value
                    Dim KOID As String = dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOID1.Index).Value
                    If D1 <> "" And D2 <> "" Then
                        If KOID = txtCustomCOID.Text Then
                            Doppelgabesätze += (KOID + "|" + dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value + "|" + D1 + "|" + D2)
                        Else
                            Doppelgabesätze += (KOID + "|" + txtCustomCOID.Text + "|" + D1 + "|" + D2)
                        End If
                    End If
                Else
                    If Not KOIDS.Contains(dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value) Then
                        Synergien += dgvTagPowers.Rows(I).Cells(dgvCCustomCOSynergie.Index).Value + "|"
                        KONamen += dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value + "|"
                        Doppelgabenamen += dgvTagPowers.Rows(I).Cells(dgvCCustomCOTagPowerName.Index).Value + "|"
                        KOIDS.Add(dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value)
                    End If
                    Dim D1 As String = dgvTagPowers.Rows(I).Cells(dgvCCustomCOText1.Index).Value
                    Dim D2 As String = dgvTagPowers.Rows(I).Cells(dgvCCustomCOSecondSentence.Index).Value
                    Dim KOID As String = dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOID1.Index).Value
                    If D1 <> "" And D2 <> "" Then
                        If KOID = txtCustomCOID.Text Then
                            Doppelgabesätze += (KOID + "|" + dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value + "|" + D1 + "|" + D2 + "|")
                        Else
                            Doppelgabesätze += (KOID + "|" + txtCustomCOID.Text + "|" + D1 + "|" + D2 + "|")
                        End If
                    End If
                End If
            Next
            strR.WriteLine("DoppelgabenKOID:" + KONamen)
            strR.WriteLine("Synergie:" + Synergien)
            strR.WriteLine("Doppelgabenamen:" + Doppelgabenamen)
            If Doppelgabesätze <> "" Then
                strR.WriteLine("Doppelgabesätze:" + Doppelgabesätze)
            End If
        End Using
        Using strR As New IO.StreamWriter("C:\Programmierung\Commander Wars\Programm\Commander Wars\Advance Wars-Der wahre Feind\Resources\!Custom\CO\" + txtCustomCOID.Text + ".CCO", False)
            strR.WriteLine("KOName:" + txtCustomCOName.Text)
            strR.WriteLine("KOID:" + txtCustomCOID.Text.ToUpper)
            strR.WriteLine("Armee:" + getArmeeID(cbCustomCOArmy.SelectedText))
            strR.WriteLine("Musik:" + txtCustomCOID.Text)
            strR.WriteLine("Sternkosten:" + nudCustomCOCostsPerStar.Value.ToString)
            strR.WriteLine("Gabekosten:" + nudCustomCOCOPCost.Value.ToString)
            strR.WriteLine("SpezialgabeKosten:" + nudCustomCOSCOPCOST.Value.ToString)
            strR.WriteLine("Gabenamen:" + txtCustomCOPName.Text + "|" + txtCustomCOSCOPName.Text)
            strR.WriteLine("KORange:" + nudCustomCOZone.Value.ToString)
            strR.WriteLine("DayToDay")
            CustomCOPowers(0).WritePower(strR)
            strR.WriteLine("COPower")
            CustomCOPowers(1).WritePower(strR)
            strR.WriteLine("SpecialPower")
            CustomCOPowers(2).WritePower(strR)
        End Using

    End Sub

    '<NonSerialized()> Dim LandschaftsStärke As Integer = 0
    '<NonSerialized()> Public LandschaftsUntergrund() As String = {}
    '<NonSerialized()> Public Bewegunssenker() As ObjektSpielfeld.Wetterarten = {}
    '<NonSerialized()> Public Bewegungswetter() As Bewegungsarten = {}
    '<NonSerialized()> Public WetterReichweitenbonus() As Integer = {-1}
    '<NonSerialized()> Public WetterartfürSenker() As ObjektSpielfeld.Wetterarten = {ObjektSpielfeld.Wetterarten.Sandsturm}

    '<NonSerialized()> Public GruppenBoost As Point() = {New Point(0, 0), New Point(0, 0)}
    '<NonSerialized()> Public AufLandschaftsStärke As Integer = 0
    '<NonSerialized()> Public AufLandschaftsUntergrund() As String = {}
    '<NonSerialized()> Public NeueBewegungskosten As Integer() = {}
    '<NonSerialized()> Public BewegungskostenUntergrund As String() = {}
    '<NonSerialized()> Public BonusEinheiten() As StringUndZahl = {}
    '<NonSerialized()> Public LandschaftsVertauschung(,) As String = {}
    '<NonSerialized()> Public Wetterimmunität As ObjektSpielfeld.Wetterarten() = {}


    Sub SavePower()
        Dim P As New KOCustom.Power()
        P.Teurungsrate = nudUnitCosts.Value
        P.GebäudeHeilung = nudHealing.Value
        P.Reichweite = nudFireRange.Value
        P.Besetzer = nudCaptureBonus.Value
        P.BonusGeldproGebäude = nudFondsBonus.Value
        P.SpritsenkungSee = nudFuelSea.Value
        P.SpritsenkungLuft = nudFuelAir.Value
        P.Wetterbouns = nudWeatherBonus.Value
        P.Wetter = cbWeatherBonus.SelectedIndex
        P.SendeTurmStärke = New Point(nudTowerPowerOff.Value, nudTowerPowerDef.Value)
        P.Zusatzdeffensive = New Point(nudDefBoostDirect.Value, nudDefBoostIndirect.Value)
        P.Gabenfüller = nudBowerbar.Value
        P.Geldstärke = nudFondsPower.Value
        P.Geldraub = nudStealFonds.Value
        P.DeckungsÄnderung = nudTerrainDeffence.Value
        P.Zusatzoffensive = New Point(nudOffBoostDirect.Value, nudOffBoostIndirect.Value)
        P.Sichtbonus = nudVisionBoost.Value
        P.DoppelAngriff = nudDoubleAttack.Value
        P.KeinGegenSchaden = Not cbCounterDamage.Checked
        P.MoveandFire = cbMoveAndFire.Checked
        P.FireandMove = cbFireAndMove.Checked
        P.StärkebonusproEinheit = nudStärkeBonus.Value
        P.Kampfbonus = cbStärkeBonus.SelectedIndex
        P.Maximalschaden = nudMaxDamage.Value
        P.Kampfverstärker = nudHPBoost.Value
        P.Lebensentzug = nudLifeRemoval.Value
        P.GegenFeuerkraft = nudCounterDef.Value
        P.NachBauZiehen = cbMoveAfterBuilding.Checked
        P.GenauesLebenAnzeigen = cbExactLife.Checked
        P.Bergbonus = New Point(nudMountainOffBoost.Value, nudMountainDistance.Value)
        P.RiffWaldSchauer = cbForestVision.Checked
        P.GeldFürEigenSchaden = nudBattleMoney.Value
        P.ATKundKostensteigererfürFonds = New Point(nudSanjuroAttackBoost.Value, nudSanjuroFondsBoost.Value)
        P.Minenstärke = nudMineBoost.Value
        P.ErhöhterGegenschadenbeiEigenSchaden = nudDamageBoost.Value
        P.MaxGlückbeiZerstörung = cbMaxLuckDestruction.Checked
        P.ZusätlicheKampfschwächeproTP = nudHPOffLoose.Value
        P.ImmerMaxGlück = cbMaxLuck.Checked
        P.FesterZusatzschadenUndDeffensive = New Point(nudFixedBoostOff.Value, nudFixedBoostDef.Value)
        P.MehrEinkommen = nudMoreIncome.Value
        P.FeuerstärkeproFeindlicherDeckung = nudTerrainBoost.Value
        P.Schadensflug = New Point(nudDamageFLyDamage.Value, nudDamageFlyFields.Value)
        P.ATKHochfürSchwacheGegner = nudOffForLowHP.Value
        P.KampfSchadenHeilung = nudFightHeal.Value
        P.Lähmschaden = nudNoMOveHP.Value
        P.ATKDEFBoostdurchZerstörung = New Point(nudDestroyBoostOff.Value, nudDestroyBoostDef.Value)
        P.AnyUnitKampfverstärker = New Point(nudRandomBoostOff.Value, nudRandomBoostMoving.Value)
        P.NochMalZiehenUndKampfänderNachZerstörung = nudDestroyMove.Value
        P.GabeleistenVerstecker = Not cbSeeCOBar.Checked
        P.FallenAngriff = cbTrapFight.Checked
        P.KeineFondsInfos = Not cbSeeFonds.Checked
        P.BewegungsKostenÄnderungNachZerstörung = New Point(nudBattleMovingPoints.Value, nudBattleMovingPlayer.Value)
        P.RadioaktiveStärke = New Point(nudRadioactivityX.Value, nudRadioactivityY.Value)
        P.FeldtarnungsReichweite = nudHidding.Value
        P.NahkampfReichweitenBonus = nudDirectRange.Value
        P.Baugebäude = cbBuildBuildings.SelectedIndex
        P.RepairON = cbRepairBuildings.SelectedIndex
        P.FeuerVerlustbeiKP = Not cbAlways10HP.Checked
        P.SpriteVertauschung = cbInfantrySprites.Checked
        P.GebäudeZusatzSchaden = nudBuildingBoost.Value
        Select Case cbOffenceTable.SelectedIndex
            Case 0
                P.OffensivStärke = New FeuerkrafttabelleCustomAlles(nudOffenceTable1.Value)
            Case 1
                P.OffensivStärke = New FeuerkrafttabelleCustomFernkampf(nudOffenceTable1.Value, nudOffenceTable2.Value)
            Case 2
                P.OffensivStärke = New FeuerkrafttabelleCustomHelis(nudOffenceTable1.Value, nudOffenceTable2.Value, nudOffenceTable3.Value, nudOffenceTable4.Value)
            Case 3
                P.OffensivStärke = New FeuerkrafttabelleCustomINF(nudOffenceTable1.Value, nudOffenceTable2.Value, nudOffenceTable3.Value)
            Case 4
                P.OffensivStärke = New FeuerkrafttabelleCustomNahkampf(nudOffenceTable1.Value, nudOffenceTable2.Value, nudOffenceTable3.Value)
            Case 5
                P.OffensivStärke = New FeuerkrafttabelleCustomSeeOffLuftOff(nudOffenceTable1.Value, nudOffenceTable2.Value, nudOffenceTable3.Value)
            Case Else
                P.OffensivStärke = New FeuerkrafttabelleCustomAlles(nudOffenceTable1.Value)
        End Select
        Select Case cbDeffenceTable.SelectedIndex
            Case 0
                P.DeffensivStärke = New FeuerkrafttabelleCustomAlles(nudDeffenceTable1.Value)
            Case 1
                P.DeffensivStärke = New FeuerkrafttabelleCustomFernkampf(nudDeffenceTable1.Value, nudDeffenceTable2.Value)
            Case 2
                P.DeffensivStärke = New FeuerkrafttabelleCustomHelis(nudDeffenceTable1.Value, nudDeffenceTable2.Value, nudDeffenceTable3.Value, nudDeffenceTable4.Value)
            Case 3
                P.DeffensivStärke = New FeuerkrafttabelleCustomINF(nudDeffenceTable1.Value, nudDeffenceTable2.Value, nudDeffenceTable3.Value)
            Case 4
                P.DeffensivStärke = New FeuerkrafttabelleCustomNahkampf(nudDeffenceTable1.Value, nudDeffenceTable2.Value, nudDeffenceTable3.Value)
            Case 5
                P.DeffensivStärke = New FeuerkrafttabelleCustomSeeOffLuftOff(nudDeffenceTable1.Value, nudDeffenceTable2.Value, nudDeffenceTable3.Value)
            Case Else
                P.DeffensivStärke = New FeuerkrafttabelleCustomAlles(nudDeffenceTable1.Value)
        End Select
        Select Case cbMovingBoostTable.SelectedIndex
            Case 0
                P.Bewegungsbonus = New BewegungsboniTabelleCustomAlles(nudMovingBoostTable.Value)
            Case 1
                P.Bewegungsbonus = New BewegungsboniTabelleCustomFern_Panzer(nudMovingBoostTable.Value)
            Case 2
                P.Bewegungsbonus = New BewegungsboniTabelleCustomHovercraft(nudMovingBoostTable.Value)
            Case 3
                P.Bewegungsbonus = New BewegungsboniTabelleCustomINF(nudMovingBoostTable.Value)
            Case 4
                P.Bewegungsbonus = New BewegungsboniTabelleCustomSee(nudMovingBoostTable.Value)
            Case 5
                P.Bewegungsbonus = New BewegungsboniTabelleCustomTransporter(nudMovingBoostTable.Value)
            Case 6
                P.Bewegungsbonus = New BewegungsboniTabelleCustomPanzer(nudMovingBoostTable.Value)
            Case 7
                P.Bewegungsbonus = New BewegungsboniTabelleCustomNahkampf(nudMovingBoostTable.Value)
        End Select
        P.ThisPowerScript = New KOCustom.Power.PowerScript
       
        CustomCOPowers(cbCustomCOPower.SelectedIndex) = P
    End Sub
    Sub LoadCustomCOPower()
        Dim P As KOCustom.Power = CustomCOPowers(cbCustomCOPower.SelectedIndex)
        nudUnitCosts.Value = P.Teurungsrate
        nudHealing.Value = P.GebäudeHeilung
        nudFireRange.Value = P.Reichweite
        nudFondsBonus.Value = P.BonusGeldproGebäude
        nudCaptureBonus.Value = P.Besetzer
        nudFuelSea.Value = P.SpritsenkungSee
        nudFuelAir.Value = P.SpritsenkungLuft
        cbWeatherBonus.SelectedIndex = P.Wetter
        nudWeatherBonus.Value = P.Wetterbouns
        nudTowerPowerOff.Value = P.SendeTurmStärke.X
        nudTowerPowerDef.Value = P.SendeTurmStärke.Y
        nudDefBoostDirect.Value = P.Zusatzdeffensive.X
        nudDefBoostIndirect.Value = P.Zusatzdeffensive.Y
        nudBowerbar.Value = P.Gabenfüller
        If P.Geldstärke < 0 Then
            nudFondsPower.Value = -1
        Else
            nudFondsPower.Value = P.Geldstärke
        End If
        nudStealFonds.Value = P.Geldraub
        nudTerrainDeffence.Value = P.DeckungsÄnderung
        nudOffBoostDirect.Value = P.Zusatzoffensive.X
        nudOffBoostIndirect.Value = P.Zusatzoffensive.Y
        nudDoubleAttack.Value = P.DoppelAngriff
        nudVisionBoost.Value = P.Sichtbonus
        cbCounterDamage.Checked = Not P.KeinGegenSchaden
        cbFireAndMove.Checked = P.FireandMove
        cbMoveAndFire.Checked = P.MoveandFire
        cbStärkeBonus.SelectedIndex = P.Kampfbonus
        nudStärkeBonus.Value = P.StärkebonusproEinheit
        nudHPBoost.Value = P.Kampfverstärker
        nudMaxDamage.Value = P.Maximalschaden
        nudLifeRemoval.Value = P.Lebensentzug
        nudCounterDef.Value = P.GegenFeuerkraft
        cbExactLife.Checked = P.GenauesLebenAnzeigen
        cbMoveAfterBuilding.Checked = P.NachBauZiehen
        nudMountainOffBoost.Value = P.Bergbonus.X
        nudMountainDistance.Value = P.Bergbonus.Y
        nudBattleMoney.Value = P.GeldFürEigenSchaden
        cbForestVision.Checked = P.RiffWaldSchauer
        nudSanjuroAttackBoost.Value = P.ATKundKostensteigererfürFonds.X
        nudSanjuroFondsBoost.Value = P.ATKundKostensteigererfürFonds.Y
        nudMineBoost.Value = P.Minenstärke
        nudDamageBoost.Value = P.ErhöhterGegenschadenbeiEigenSchaden
        cbMaxLuckDestruction.Checked = P.MaxGlückbeiZerstörung
        nudHPOffLoose.Value = P.ZusätlicheKampfschwächeproTP
        cbMaxLuck.Checked = P.ImmerMaxGlück
        nudFixedBoostOff.Value = P.FesterZusatzschadenUndDeffensive.X
        nudFixedBoostDef.Value = P.FesterZusatzschadenUndDeffensive.Y
        nudTerrainBoost.Value = P.FeuerstärkeproFeindlicherDeckung
        nudMoreIncome.Value = P.MehrEinkommen
        nudOffForLowHP.Value = P.ATKHochfürSchwacheGegner
        nudDamageFLyDamage.Value = P.Schadensflug.X
        nudDamageFlyFields.Value = P.Schadensflug.Y
        nudNoMOveHP.Value = P.Lähmschaden
        nudFightHeal.Value = P.KampfSchadenHeilung
        nudRandomBoostOff.Value = P.AnyUnitKampfverstärker.X
        nudRandomBoostMoving.Value = P.AnyUnitKampfverstärker.Y
        nudDestroyBoostOff.Value = P.ATKDEFBoostdurchZerstörung.X
        nudDestroyBoostDef.Value = P.ATKDEFBoostdurchZerstörung.Y
        nudDestroyMove.Value = P.NochMalZiehenUndKampfänderNachZerstörung
        cbSeeCOBar.Checked = Not P.GabeleistenVerstecker
        cbSeeFonds.Checked = Not P.KeineFondsInfos
        cbTrapFight.Checked = P.FallenAngriff
        cbNoRepairFight.Checked = P.ReperaturVerbotNachKampf
        nudCaptureFight.Value = P.BesetzungsbonusNachEinheitenZerstörung
        nudBattleMovingPoints.Value = P.BewegungsKostenÄnderungNachZerstörung.X
        nudBattleMovingPlayer.Value = P.BewegungsKostenÄnderungNachZerstörung.Y
        nudRadioactivityX.Value = P.RadioaktiveStärke.X
        nudRadioactivityY.Value = P.RadioaktiveStärke.Y
        nudHidding.Value = P.FeldtarnungsReichweite
        nudDirectRange.Value = P.NahkampfReichweitenBonus
        cbBuildBuildings.SelectedIndex = P.Baugebäude
        cbRepairBuildings.SelectedIndex = P.RepairON
        cbAlways10HP.Checked = Not P.FeuerVerlustbeiKP
        cbInfantrySprites.Checked = P.SpriteVertauschung
        nudBuildingBoost.Value = P.GebäudeZusatzSchaden
        'Offensiv Stärke
        If TypeOf P.OffensivStärke Is FeuerkrafttabelleCustomAlles Then
            cbOffenceTable.SelectedIndex = 0
            nudOffenceTable1.Value = P.OffensivStärke.GetWert("INF")
        ElseIf TypeOf P.OffensivStärke Is FeuerkrafttabelleCustomFernkampf Then
            cbOffenceTable.SelectedIndex = 2
            nudOffenceTable1.Value = P.OffensivStärke.GetWert("ART")
            nudOffenceTable2.Value = P.OffensivStärke.GetWert("TTP")
        ElseIf TypeOf P.OffensivStärke Is FeuerkrafttabelleCustomHelis Then
            cbOffenceTable.SelectedIndex = 4
            nudOffenceTable1.Value = P.OffensivStärke.GetWert("K-HELI")
            nudOffenceTable2.Value = P.OffensivStärke.GetWert("INF")
            nudOffenceTable3.Value = P.OffensivStärke.GetWert("KPZ")
            nudOffenceTable4.Value = P.OffensivStärke.GetWert("BOMBER")
        ElseIf TypeOf P.OffensivStärke Is FeuerkrafttabelleCustomINF Then
            cbOffenceTable.SelectedIndex = 5
            nudOffenceTable1.Value = P.OffensivStärke.GetWert("BOMBER")
            nudOffenceTable2.Value = P.OffensivStärke.GetWert("INF")
            nudOffenceTable3.Value = P.OffensivStärke.GetWert("KPZ")
        ElseIf TypeOf P.OffensivStärke Is FeuerkrafttabelleCustomNahkampf Then
            cbOffenceTable.SelectedIndex = 3
            nudOffenceTable1.Value = P.OffensivStärke.GetWert("KPZ")
            nudOffenceTable2.Value = P.OffensivStärke.GetWert("INF")
            nudOffenceTable3.Value = P.OffensivStärke.GetWert("ART")
        ElseIf TypeOf P.OffensivStärke Is FeuerkrafttabelleCustomSeeOffLuftOff Then
            cbOffenceTable.SelectedIndex = 1
            nudOffenceTable1.Value = P.OffensivStärke.GetWert("BOMBER")
            nudOffenceTable2.Value = P.OffensivStärke.GetWert("KREUZER")
            nudOffenceTable3.Value = P.OffensivStärke.GetWert("KPZ")
        Else
            cbOffenceTable.SelectedIndex = 0
            nudOffenceTable1.Value = P.OffensivStärke.GetWert("INF")
        End If
        'Deffensiv Stärke
        If TypeOf P.DeffensivStärke Is FeuerkrafttabelleCustomAlles Then
            cbDeffenceTable.SelectedIndex = 0
            nudDeffenceTable1.Value = P.DeffensivStärke.GetWert("INF")
        ElseIf TypeOf P.DeffensivStärke Is FeuerkrafttabelleCustomFernkampf Then
            cbDeffenceTable.SelectedIndex = 2
            nudDeffenceTable1.Value = P.DeffensivStärke.GetWert("ART")
            nudDeffenceTable2.Value = P.DeffensivStärke.GetWert("TTP")
        ElseIf TypeOf P.DeffensivStärke Is FeuerkrafttabelleCustomHelis Then
            cbDeffenceTable.SelectedIndex = 4
            nudDeffenceTable1.Value = P.DeffensivStärke.GetWert("K-HELI")
            nudDeffenceTable2.Value = P.DeffensivStärke.GetWert("INF")
            nudDeffenceTable3.Value = P.DeffensivStärke.GetWert("KPZ")
            nudDeffenceTable4.Value = P.DeffensivStärke.GetWert("BOMBER")
        ElseIf TypeOf P.DeffensivStärke Is FeuerkrafttabelleCustomINF Then
            cbDeffenceTable.SelectedIndex = 5
            nudDeffenceTable1.Value = P.DeffensivStärke.GetWert("BOMBER")
            nudDeffenceTable2.Value = P.DeffensivStärke.GetWert("INF")
            nudDeffenceTable3.Value = P.DeffensivStärke.GetWert("KPZ")
        ElseIf TypeOf P.DeffensivStärke Is FeuerkrafttabelleCustomNahkampf Then
            cbDeffenceTable.SelectedIndex = 3
            nudDeffenceTable1.Value = P.DeffensivStärke.GetWert("KPZ")
            nudDeffenceTable2.Value = P.DeffensivStärke.GetWert("INF")
            nudDeffenceTable3.Value = P.DeffensivStärke.GetWert("ART")
        ElseIf TypeOf P.DeffensivStärke Is FeuerkrafttabelleCustomSeeOffLuftOff Then
            cbDeffenceTable.SelectedIndex = 1
            nudDeffenceTable1.Value = P.DeffensivStärke.GetWert("BOMBER")
            nudDeffenceTable2.Value = P.DeffensivStärke.GetWert("KREUZER")
            nudDeffenceTable3.Value = P.DeffensivStärke.GetWert("KPZ")
        Else
            cbDeffenceTable.SelectedIndex = 0
            nudDeffenceTable1.Value = P.DeffensivStärke.GetWert("INF")
        End If
        'Moving Boost
        If TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomAlles Then
            cbMovingBoostTable.SelectedIndex = 0
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("INF")
        ElseIf TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomFern_Panzer Then
            cbMovingBoostTable.SelectedIndex = 1
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("KPZ")
        ElseIf TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomHovercraft Then
            cbMovingBoostTable.SelectedIndex = 2
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("ABPZ")
        ElseIf TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomINF Then
            cbMovingBoostTable.SelectedIndex = 3
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("INF")
        ElseIf TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomSee Then
            cbMovingBoostTable.SelectedIndex = 4
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("KREUZER")
        ElseIf TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomTransporter Then
            cbMovingBoostTable.SelectedIndex = 5
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("TTP")
        ElseIf TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomPanzer Then
            cbMovingBoostTable.SelectedIndex = 6
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("KPZ")
        ElseIf TypeOf P.Bewegungsbonus Is BewegungsboniTabelleCustomNahkampf Then
            cbMovingBoostTable.SelectedIndex = 7
            nudMovingBoostTable.Value = P.Bewegungsbonus.GetWert("KPZ")
        End If
        If CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript Is Nothing Then
            CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript = New KOCustom.Power.PowerScript
        End If
        lbCustomEvents.Items.Clear()
        If CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects.Count > 0 Then
            For Each Effect In CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects
                lbCustomEvents.Items.Add(Effect.ToString.Split(":")(0))
            Next
        Else
            lbCustomEvents.Items.Add("Effects")
        End If
    End Sub
    Sub OpenCustomCO()
        OpenFileDialog1.Title = "Open Custom CO"
        OpenFileDialog1.DefaultExt = ".CCO"
        OpenFileDialog1.Filter = "Custom CO's|*.cco"
        OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\CO\"
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            If My.Computer.FileSystem.FileExists(OpenFileDialog1.FileName) Then
                LoadCustomCO(OpenFileDialog1.FileName)
            End If
        End If
    End Sub

    ''' <summary>
    ''' Lädt einen Custom KO
    ''' </summary>
    ''' <param name="File"></param>
    ''' <remarks></remarks>
    Sub LoadCustomCO(ByVal File As String)
        Dim K As New KOCustom()
        K.StartwerteLaden(File)
        txtCustomCOID.Text = K.KOID
        CustomCOPowers = K.KOWerte
        LoadCustomCOPower()
        cbCustomCOArmy.SelectedText = K.Armee
        nudCustomCOCostsPerStar.Value = K.Sternkosten
        nudCustomCOZone.Value = K.KORange
        Dim Synergie As Decimal() = {}
        Dim Doppelgabenamen As String() = {}
        Dim Doppelgabesätze As ObjektKOBeschreibung.DoppelGabesatz() = {}
        Dim KONamen As String() = {}
        File = File.ToUpper
        Dim F As String = File.Replace(".CCO", ".desc")
        Dim S() As String = F.Split("\")
        F = ""
        For I = 0 To S.Length - 1
            If I = S.Length - 2 Then
                F += S(I) + "\" + "CO Desc\"
            ElseIf I = S.Length - 1 Then
                F += S(I)
            Else
                F += S(I) + "\"
            End If
        Next
        If My.Computer.FileSystem.FileExists(F) Then
            Using Reader As New System.IO.StreamReader(F)
                While Not Reader.EndOfStream
                    Dim Zeile As String = Reader.ReadLine.Trim
                    If Zeile.ToLower.StartsWith("name:") Then
                        txtCustomCOName.Text = Zeile.Remove(0, 5)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("koid:") Then
                        txtCustomCOID.Text = Zeile.Remove(0, 5)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("fein:") Then
                        txtCustomCOHit.Text = Zeile.Remove(0, 5)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("nein:") Then
                        txtCustomCOMiss.Text = Zeile.Remove(0, 5)
                        Continue While
                    End If

                    If Zeile.ToLower.StartsWith("gaben:") Then
                        Dim Gaben() As String = Zeile.Remove(0, 6).Split("|")
                        txtCustomCOPName.Text = Gaben(0)
                        txtCustomCOSCOPName.Text = Gaben(1)
                        Continue While
                    End If

                    If Zeile.ToLower.StartsWith("beschreibung:") Then
                        txtCustomCOInfo.Text = Zeile.Remove(0, 13)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("stil:") Then
                        txtCustomCOStyle.Text = Zeile.Remove(0, 5)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("gabebeschreibung:") Then
                        txtCustomCOCOP.Text = Zeile.Remove(0, 17)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("spezialgabebeschreibung:") Then
                        txtCustomCOSCOP.Text = Zeile.Remove(0, 24)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("gabesätze:") Then
                        Dim Gabesätze() As String = Zeile.Remove(0, 10).Split("|")
                        If Gabesätze.Length > 0 Then
                            txtCustomCOCOPText1.Text = Gabesätze(0)
                            If Gabesätze.Length > 1 Then
                                txtCustomCOCOPText2.Text = Gabesätze(1)
                                If Gabesätze.Length > 2 Then
                                    txtCustomCOCOPText3.Text = Gabesätze(2)
                                    If Gabesätze.Length > 3 Then
                                        txtCustomCOCOPText4.Text = Gabesätze(3)
                                        If Gabesätze.Length > 4 Then
                                            txtCustomCOCOPText5.Text = Gabesätze(4)
                                        End If
                                    End If
                                End If
                            End If
                        End If
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("siegsätze:") Then
                        Dim Siegsätze() As String = Zeile.Remove(0, 10).Split("|")
                        If Siegsätze.Length > 0 Then
                            txtCustomCOWinText1.Text = Siegsätze(0)
                            If Siegsätze.Length > 1 Then
                                txtCustomCOWinText2.Text = Siegsätze(1)
                            End If
                        End If
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("tauschsätze:") Then
                        Dim Tauschsätze() As String = Zeile.Remove(0, 12).Split("|")
                        If Tauschsätze.Length > 0 Then
                            txtCustomCOChange1.Text = Tauschsätze(0)
                            If Tauschsätze.Length > 1 Then
                                txtCustomCOChange2.Text = Tauschsätze(1)
                            End If
                        End If
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("doppelgabesätze:") Then
                        'Das hier mache ich noch
                        Array.Resize(Doppelgabesätze, 0)
                        Dim Sätze As String() = Zeile.Remove(0, 16).Split("|")
                        Array.Resize(Doppelgabesätze, Math.DivRem(Sätze.Length, 4, 0))
                        For I2 = 0 To Doppelgabesätze.Length - 1
                            Doppelgabesätze(I2) = New ObjektKOBeschreibung.DoppelGabesatz(Sätze(I2 * 4 + 0), Sätze(I2 * 4 + 1), Sätze(I2 * 4 + 2), Sätze(I2 * 4 + 3))
                        Next
                        Continue While
                    End If

                    If Zeile.ToLower.StartsWith("doppelgabenamen:") Then
                        Doppelgabenamen = Zeile.Remove(0, 16).Split("|")
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("doppelgabenkoid:") Then
                        KONamen = Zeile.Remove(0, 16).Split("|")
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("synergie:") Then
                        Synergie = ToDecArry(Zeile.Remove(0, 9).Split("|"))
                        Continue While
                    End If

                    If Zeile.ToLower.StartsWith("gabekosten:") Then
                        nudCustomCOCOPCost.Value = Zeile.Remove(0, 11)
                        Continue While
                    End If
                    If Zeile.ToLower.StartsWith("spezialgabekosten:") Then
                        nudCustomCOSCOPCOST.Value = Zeile.Remove(0, 18)
                        Continue While
                    End If

                End While
            End Using
            For I = 0 To Synergie.Length - 1
                dgvTagPowers.Rows.Add()
                dgvTagPowers.Rows(I).Cells(dgvCCustomCOCOSynergieID.Index).Value = KONamen(I)
                dgvTagPowers.Rows(I).Cells(dgvCCustomCOSynergie.Index).Value = Synergie(I)
                dgvTagPowers.Rows(I).Cells(dgvCCustomCOTagPowerName.Index).Value = Doppelgabenamen(I)
            Next

            For I = 0 To Doppelgabesätze.Length - 1
                Dim Added As Boolean = False
                Dim FirstFound As Integer = -1
                For I2 = 0 To dgvTagPowers.RowCount - 2
                    If dgvTagPowers.Rows(I2).Cells(dgvCCustomCOCOSynergieID.Index).Value = Doppelgabesätze(I).KOID1 Or dgvTagPowers.Rows(I2).Cells(dgvCCustomCOCOSynergieID.Index).Value = Doppelgabesätze(I).KOID2 Then
                        If FirstFound < 0 Then
                            FirstFound = I
                        End If
                        If dgvTagPowers.Rows(I2).Cells(dgvCCustomCOText1.Index).Value = "" Then
                            Added = True
                            dgvTagPowers.Rows(I2).Cells(dgvCCustomCOText1.Index).Value = Doppelgabesätze(I).KOSatz1
                            dgvTagPowers.Rows(I2).Cells(dgvCCustomCOSecondSentence.Index).Value = Doppelgabesätze(I).KOSatz2
                            dgvTagPowers.Rows(I2).Cells(dgvCCustomCOCOID1.Index).Value = Doppelgabesätze(I).KOID1
                        End If
                    End If
                    If Added Then
                        Exit For
                    ElseIf I2 = dgvTagPowers.RowCount - 2 Then
                        dgvTagPowers.Rows.Add()
                        dgvTagPowers.Rows(I2 + 1).Cells(dgvCCustomCOCOSynergieID.Index).Value = dgvTagPowers.Rows(FirstFound).Cells(dgvCCustomCOCOSynergieID.Index).Value
                        dgvTagPowers.Rows(I2 + 1).Cells(dgvCCustomCOSynergie.Index).Value = dgvTagPowers.Rows(FirstFound).Cells(dgvCCustomCOSynergie.Index).Value
                        dgvTagPowers.Rows(I2 + 1).Cells(dgvCCustomCOTagPowerName.Index).Value = dgvTagPowers.Rows(FirstFound).Cells(dgvCCustomCOTagPowerName.Index).Value
                        dgvTagPowers.Rows(I2 + 1).Cells(dgvCCustomCOText1.Index).Value = Doppelgabesätze(I).KOSatz1
                        dgvTagPowers.Rows(I2 + 1).Cells(dgvCCustomCOSecondSentence.Index).Value = Doppelgabesätze(I).KOSatz2
                        dgvTagPowers.Rows(I2 + 1).Cells(dgvCCustomCOCOID1.Index).Value = Doppelgabesätze(I).KOID1
                    End If
                Next
            Next
        End If
    End Sub

    'Subroutines
    Sub setDefaultLandkarte()
        txtLandkarteName.Text = ""
        txtLandkarteHintergrund.Text = ""
        cbLandkarteKomprimiert.Checked = False
        cmbLandkarteGameMode.SelectedIndex = 0

        dgvLandkarteBlockierteEinheiten.Rows.Clear()
        dgvLandkarteMissionen.Rows.Clear()
    End Sub


    ''' <summary>
    ''' fügt einen neuen Spieler unten in die Statistik hinzu
    ''' </summary>
    ''' <param name="i">der index des Spielers. 0 ist er erste</param>
    ''' <param name="Team"></param>
    ''' <param name="KI"></param>
    ''' <param name="Farbe"></param>
    ''' <param name="Startgeld"></param>
    ''' <param name="FondsPS"></param>
    ''' <param name="FondsPF"></param>
    ''' <param name="Unbesiegbar"></param>
    ''' <param name="Bauliste"></param>
    ''' <param name="KO1">Bitte gleich in der passenden Form und übersetzt ins Englische, oder Deutsche. Je nachdem eben :) z.B.:[getKOString("ANDY")]</param>
    ''' <param name="KO2">Bitte gleich in der passenden Form und übersetzt ins Englische, oder Deutsche. Je nachdem eben :) z.B.:[getKOString("-")]</param>
    ''' <remarks></remarks>
    Public Sub addSpielerInSpielerinfos(ByVal i As Integer, ByVal Team As Char, ByVal KI As Integer, ByVal Farbe As String, ByVal Startgeld As Integer, ByVal FondsPS As Integer, ByVal FondsPF As Integer, ByVal Unbesiegbar As Boolean, ByVal Bauliste As Integer, ByVal KO1 As String, ByVal KO2 As String)
        'FARBE:
        Dim btnFarbe As New ComboBox
        btnFarbe.Left = 5
        btnFarbe.Top = OffsetOben + i * Reihenhöhe
        btnFarbe.Size = New Size(120, btnFarbe.Size.Height)
        ToolTip1.SetToolTip(btnFarbe, (i + 1).ToString + ": the color of the player")
        SetCmbFarbtabellen(btnFarbe.Items)
        btnFarbe.SelectedItem = getFarbtabellenString(Farbe)
        btnFarbe.DropDownStyle = ComboBoxStyle.DropDownList

        pSpielerdaten.Controls.Add(btnFarbe)
        _btnFarbe(i) = btnFarbe




        'TEAM:
        Dim lblTeam As New ComboBox
        lblTeam.Left = _btnFarbe(i).Location.X + _btnFarbe(i).Size.Width + OffsetBreiteZuNachbar
        lblTeam.Size = New Size(40, lblTeam.Size.Height)
        lblTeam.Top = OffsetOben + i * Reihenhöhe
        ToolTip1.SetToolTip(lblTeam, (i + 1).ToString + ": the team of the player")
        SetCmbTeams(lblTeam.Items)
        lblTeam.SelectedItem = Team.ToString
        lblTeam.DropDownStyle = ComboBoxStyle.DropDownList

        pSpielerdaten.Controls.Add(lblTeam)
        _lblTeam(i) = lblTeam



        'KI:
        Dim dud As New ComboBox
        dud.DropDownStyle = ComboBoxStyle.DropDownList
        dud.Items.Clear()
        dud.Items.Add("Human")
        dud.Items.Add("very Easy")
        dud.Items.Add("Easy")
        dud.Items.Add("Normal")
        dud.SelectedIndex = KI
        If dud.SelectedIndex = -1 Then
            dud.SelectedIndex = 0
        End If
        dud.Size = New Size(100, dud.Size.Height)
        dud.Left = _lblTeam(i).Location.X + _lblTeam(i).Size.Width + OffsetBreiteZuNachbar
        dud.Top = OffsetOben + i * Reihenhöhe
        ToolTip1.SetToolTip(dud, (i + 1).ToString + ": AI difficulty or human controlled")
        pSpielerdaten.Controls.Add(dud)
        _cmbKI(i) = dud





        'KO:
        dud = New ComboBox
        dud.DropDownStyle = ComboBoxStyle.DropDownList
        dud.Items.Clear()
        addKOToDomain(dud)
        dud.SelectedItem = KO1
        If dud.SelectedIndex = -1 Then
            dud.SelectedIndex = 0
        End If
        dud.Left = _cmbKI(i).Location.X + _cmbKI(i).Size.Width + OffsetBreiteZuNachbar
        dud.Top = OffsetOben + i * Reihenhöhe
        ToolTip1.SetToolTip(dud, (i + 1).ToString + ": the 1st. Commander")
        pSpielerdaten.Controls.Add(dud)
        _cmbKO1(i) = dud



        dud = New ComboBox
        dud.DropDownStyle = ComboBoxStyle.DropDownList
        dud.Items.Clear()
        dud.Items.Add("-")
        addKOToDomain(dud)
        dud.SelectedItem = KO2
        If dud.SelectedIndex = -1 Then
            dud.SelectedIndex = 0
        End If
        dud.Left = _cmbKO1(i).Location.X + _cmbKO1(i).Size.Width + OffsetBreiteZuNachbar
        dud.Top = OffsetOben + i * Reihenhöhe
        ToolTip1.SetToolTip(dud, (i + 1).ToString + ": the 2nd. Commander")
        pSpielerdaten.Controls.Add(dud)
        _cmbKO2(i) = dud





        'STARTGELD:
        Dim nud As New NumericUpDown
        nud.Minimum = 0
        nud.Maximum = 9999999
        nud.Value = Startgeld
        nud.Left = _cmbKO2(i).Location.X + _cmbKO2(i).Size.Width + OffsetBreiteZuNachbar
        nud.Top = OffsetOben + i * Reihenhöhe
        nud.Size = New Size(77, nud.Size.Height)
        ToolTip1.SetToolTip(nud, (i + 1).ToString + ": Fonds at the Beginning of the Game.")
        pSpielerdaten.Controls.Add(nud)
        _numStartGeld(i) = nud




        'FONDSPS:
        nud = New NumericUpDown
        nud.Minimum = 0
        nud.Maximum = 9999999
        nud.Value = FondsPS
        nud.Left = _numStartGeld(i).Location.X + _numStartGeld(i).Size.Width + OffsetBreiteZuNachbar
        nud.Top = OffsetOben + i * Reihenhöhe
        nud.Size = New Size(77, nud.Size.Height)
        ToolTip1.SetToolTip(nud, (i + 1).ToString + ": Fonds per City which the player owns")
        pSpielerdaten.Controls.Add(nud)
        _numFondspS(i) = nud



        'FONDSPF:
        nud = New NumericUpDown
        nud.Minimum = 0
        nud.Maximum = 9999999
        nud.Value = FondsPF
        nud.Left = _numFondspS(i).Location.X + _numFondspS(i).Size.Width + OffsetBreiteZuNachbar
        nud.Top = OffsetOben + i * Reihenhöhe
        nud.Size = New Size(77, nud.Size.Height)
        ToolTip1.SetToolTip(nud, (i + 1).ToString + ": Fonds for the factory")
        pSpielerdaten.Controls.Add(nud)
        _numFondspF(i) = nud






        'UNBESIEGBAR:
        Dim cbImbar As New CheckBox
        cbImbar.Top = OffsetOben + i * Reihenhöhe
        cbImbar.Left = _numFondspF(i).Location.X + _numFondspF(i).Size.Width + OffsetBreiteZuNachbar
        cbImbar.Size = New Size(120, cbImbar.Size.Height)
        cbImbar.Text = "unconquerable"
        cbImbar.Checked = Unbesiegbar
        ToolTip1.SetToolTip(cbImbar, (i + 1).ToString + ": if this box is checked, the Player can't be defeated")
        pSpielerdaten.Controls.Add(cbImbar)
        _cbUnbesiegbar(i) = cbImbar



        'BAULISTE:
        dud = New ComboBox
        dud.DropDownStyle = ComboBoxStyle.DropDownList
        dud.Items.Clear()
        dud.Items.AddRange([Enum].GetNames(Baulisten.CoW2.GetType))
        dud.SelectedIndex = Bauliste
        If dud.SelectedIndex = -1 Then
            dud.SelectedIndex = 0
        End If
        dud.Left = _cbUnbesiegbar(i).Location.X + _cbUnbesiegbar(i).Size.Width + OffsetBreiteZuNachbar
        dud.Top = OffsetOben + i * Reihenhöhe
        ToolTip1.SetToolTip(dud, (i + 1).ToString + ": the list of units, the player can build")
        pSpielerdaten.Controls.Add(dud)
        _cmbBauliste(i) = dud
    End Sub
    Sub addKOToDomain(ByVal dud As ComboBox)

        If KOID.Length > 0 Then
            For i = 0 To KOID.Length - 1
                dud.Items.Add(KOÜbersetzt(i))
            Next
            Exit Sub
        End If

        dud.Items.Add("Andy")
        dud.Items.Add("Max")
        dud.Items.Add("Tami")
        dud.Items.Add("Nell")
        dud.Items.Add("Hachi")

        dud.Items.Add("Olaf")
        dud.Items.Add("Kid")
        dud.Items.Add("Colin")

        dud.Items.Add("Kanbei")
        dud.Items.Add("Sensei")
        dud.Items.Add("Sonja")
        dud.Items.Add("Rattigan")

        dud.Items.Add("Eagle")
        dud.Items.Add("Drake")
        dud.Items.Add("Jess")

        dud.Items.Add("Kat")
        dud.Items.Add("Maverik")
        dud.Items.Add("Helmut")
        dud.Items.Add("Jugger")
    End Sub

    Sub NewScript(Optional ByVal Txt As String = "", Optional ByVal Fokus As Boolean = False)
        Dim ind As Integer
        If Txt = "" Then
            Dim i As Integer = lbScripts.Items.Count + 1
            ind = lbScripts.Items.Add("Script " + i.ToString)
        Else
            ind = lbScripts.Items.Add(Txt)
        End If
        Array.Resize(scripte, scripte.Length + 1)
        scripte(scripte.Length - 1) = New objScript
        scripte(scripte.Length - 1).Desc = Txt
        scInd = ind

        If Fokus Then
            lbScripts.SelectedIndex = scInd
        End If
    End Sub


    Sub addScriptBedingung(ByVal ScriptInd As Integer, ByVal Bedingungsart As Bedingungsarten, ByVal Parameter() As String)
        If ScriptInd < 0 Then Exit Sub
        scripte(ScriptInd).addBedingung(Bedingungsart, Parameter)
    End Sub
    Sub addScriptBedingung(ByVal ScriptInd As Integer, ByVal Bedingungsart As Bedingungsarten)
        If ScriptInd < 0 Then Exit Sub
        scripte(ScriptInd).addBedingung(Bedingungsart)
    End Sub
    Sub addScriptBedingung(ByVal Bedingungsart As Bedingungsarten, ByVal Parameter() As String)
        If scInd < 0 Then Exit Sub
        addScriptBedingung(scInd, Bedingungsart, Parameter)
    End Sub

    Sub addScriptEreignis(ByVal ScriptInd As Integer, ByVal Ereignisart As Ereignisarten, ByVal Parameter() As String)
        If ScriptInd < 0 Then Exit Sub
        scripte(ScriptInd).addEreignis(Ereignisart, Parameter)
    End Sub
    Sub addScriptEreignis(ByVal ScriptInd As Integer, ByVal Ereignisart As Ereignisarten)
        If ScriptInd < 0 Then Exit Sub
        scripte(ScriptInd).addEreignis(Ereignisart)
    End Sub
    Sub addScriptEreignis(ByVal Ereignisart As Bedingungsarten, ByVal Parameter() As String)
        If scInd < 0 Then Exit Sub
        addScriptEreignis(scInd, Ereignisart, Parameter)
    End Sub

    Sub deleteScriptBedingung(ByVal ScriptInd As Integer, ByVal BedingungsInd As Integer)
        If ScriptInd < 0 Then Exit Sub
        If BedingungsInd < 0 Then Exit Sub
        For i = BedingungsInd To scripte(ScriptInd).Bedingungen.Length - 2
            scripte(ScriptInd).Bedingungen(i) = scripte(ScriptInd).Bedingungen(i + 1)
        Next

        Array.Resize(scripte(ScriptInd).Bedingungen, scripte(ScriptInd).Bedingungen.Length - 1)
        If scInd = ScriptInd And BedingungsInd = scConditionInd Then
            'Wir arbeiten gerade an dem aktuellen script, mit der aktuellen bedingung
            If scripte(ScriptInd).Bedingungen.Length <= scConditionInd Then scConditionInd -= 1
        End If
        ScriptBedingungAktualisieren()
    End Sub
    Sub deleteScriptEreignis(ByVal ScriptInd As Integer, ByVal EreignisInd As Integer)
        If ScriptInd < 0 Then Exit Sub
        If EreignisInd < 0 Then Exit Sub

        For i = EreignisInd To scripte(ScriptInd).Ereignisse.Length - 2
            scripte(ScriptInd).Ereignisse(i) = scripte(ScriptInd).Ereignisse(i + 1)
        Next
        Array.Resize(scripte(ScriptInd).Ereignisse, scripte(ScriptInd).Ereignisse.Length - 1)
        If scInd = ScriptInd And EreignisInd = scEventInd Then If scripte(ScriptInd).Ereignisse.Length <= scEventInd Then scEventInd -= 1



        ScriptEreignisAktualisieren()
    End Sub
    Sub deleteCustomCOEffect(ByVal Effect As Integer)
        If lbCustomEvents.Items(0) <> "Effects" Then
            If Effect < CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects.Count Then
                CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects.RemoveAt(Effect)
                lbCustomEvents.Items.RemoveAt(Effect)
            End If
        End If
        COScriptEffektAktualisieren()
    End Sub

    Sub ScriptBedingungAktualisieren()
        If scInd < 0 Then Exit Sub
        'Conditions:
        lbScriptCondition.Items.Clear()
        For Each Cond In scripte(scInd).Bedingungen
            lbScriptCondition.Items.Add(getConditionString(Cond.Bedingungsart.ToString))
        Next
    End Sub
    Sub ScriptEreignisAktualisieren()
        If scInd < 0 Then Exit Sub
        lbScriptEvent.Items.Clear()
        For Each Ev In scripte(scInd).Ereignisse
            lbScriptEvent.Items.Add(getEventString(Ev.Ereignisart.ToString))
        Next
    End Sub
    Sub COScriptEffektAktualisieren()
        If lbCustomEvents.Items.Count > 0 Then
            'Conditions:
            lbCustomEvents.Items.Clear()
            For Each Effect In CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects
                lbCustomEvents.Items.Add(Effect.ToString.Split(":")(0))
            Next
        End If
    End Sub

    Sub DeleteScriptInListBoxCurrent()
        If lbScripts.Items.Count > 0 Then
            'Solange es noch items gibt, kann man auch welche löschen ;)
            lbScripts.Items.RemoveAt(scInd)
            For iSc = scInd To scripte.Length - 2
                scripte(iSc) = scripte(iSc + 1)
            Next
            Array.Resize(scripte, scripte.Length - 1)
            If lbScripts.Items.Count <= scInd Then scInd -= 1 'evtl. auf das nächst niedrigere Item zurückwechseln, falls es keine weiteren mehr gibt.
            lbScripts.SelectedItem = scInd
        End If
        ScriptIndChanged()
    End Sub


    Sub SaveConditions()
        If scConditionInd < 0 Then Exit Sub
        If lbScriptCondition.Items.Count <= scConditionInd Then Exit Sub
        If AktuelleBedingung Is Nothing Then Exit Sub



        If scConditionInd < 0 Then Exit Sub
        If scInd < 0 Then Exit Sub

        For i = 0 To 6
            If _condParalbl(i).Visible Then
                'Den Parameter gibt's
                If _condParanum(i).Visible Then
                    'eine Zahl!
                    AktuelleBedingung.Parameter(i) = _condParanum(i).Value
                Else
                    'eine Combobox!
                    Select Case AktuelleBedingung.Bedingungsart
                        Case Bedingungsarten.Sieg
                            AktuelleBedingung.Parameter(i) = _condParacmb(i).SelectedItem
                        Case Bedingungsarten.VariableGleich, Bedingungsarten.VariableGrößer, Bedingungsarten.VariableGrößerGleich, _
                             Bedingungsarten.VariableKleiner
                            AktuelleBedingung.Parameter(i) = _condParacmb(i).Text
                        Case Else
                            AktuelleBedingung.Parameter(i) = _condParacmb(i).SelectedIndex
                    End Select
                End If
            End If
        Next
        scripte(scInd).Bedingungen(scConditionInd) = AktuelleBedingung


        lbScriptCondition.Items.RemoveAt(scConditionInd)
        lbScriptCondition.Items.Insert(scConditionInd, cmbScriptConditionArt.SelectedItem)
        lbScriptCondition.SelectedIndex = scConditionInd
    End Sub
    Sub SaveEvents()
        If scEventInd < 0 Then Exit Sub
        If lbScriptEvent.Items.Count <= scEventInd Then Exit Sub
        If AktuellesEreignis Is Nothing Then Exit Sub



        If scEventInd < 0 Then Exit Sub
        If scInd < 0 Then Exit Sub


        If AktuellesEreignis.Ereignisart = Ereignisarten.Dialog Then
            'Totale Ausnahme
            Dim Dialog As objEreignis = AktuellesEreignis
            Dim alterDialog As objEreignis = Nothing
            For i = 0 To dgvScriptDialog.Rows.Count - 2
                'Die Texte in den Sprachkonverter schreiben..
                Dim de As String = ""
                Dim en As String = ""
                de = dgvScriptDialog(SpalteScriptDialogTextDeutsch.Index, i).Value
                en = dgvScriptDialog(SpalteScriptDialogTextEnglish.Index, i).Value
                If en = "" Then en = de
                If de = "" Then de = en
                Dim ID As Integer = 0
                SprachKonvScript.AddEintrag("Deutsch", de, ID)
                If Not SprachKonvScript.AddEintrag("English", en, ID) Then SprachKonvScript.AddEintrag("Deutsch", de, ID)
                'und anschließend den Dialog abspeichern
                Dim Gesichtsausdruck As Integer
                Select Case dgvScriptDialog(SpalteScriptDialogGesichtsausdruck.Index, i).Value.ToString.ToLower
                    Case "Happy".ToLower
                        Gesichtsausdruck = 1
                    Case "Sad".ToLower
                        Gesichtsausdruck = 2
                    Case Else
                        Gesichtsausdruck = 0
                End Select
                Dialog.Parameter = New String() {getKOID(dgvScriptDialog(SpalteScriptDialogKO.Index, i).Value), dgvScriptDialog(SpalteScriptDialogFarbe.Index, i).Value, Gesichtsausdruck, dgvScriptDialog(SpalteScriptDialogMusik.Index, i).Value, dgvScriptDialog(SpalteScriptDialogBild.Index, i).Value, "%Language%" + ID.ToString + "%"}
                If Dialog.folgeDialog Is Nothing Then
                    Dialog.folgeDialog = New objEreignis(Ereignisarten.Dialog)
                End If
                alterDialog = Dialog
                Dialog = Dialog.folgeDialog
            Next
            If alterDialog IsNot Nothing Then
                alterDialog.folgeDialog = Nothing
            End If
        Else
            For i = 0 To 6
                If _EventParalbl(i).Visible Then
                    If _EventParanum(i).Visible Then
                        AktuellesEreignis.Parameter(i) = _EventParanum(i).Value
                    Else
                        Select Case AktuellesEreignis.Ereignisart
                            Case Ereignisarten.SetVariable, Ereignisarten.NewVariable, Ereignisarten.IncreaseVariable
                                AktuellesEreignis.Parameter(i) = _EventParacmb(i).Text
                            Case Else
                                If AktuellesEreignis.Ereignisart = Ereignisarten.Dialog And i = 0 Then
                                    AktuellesEreignis.Parameter(i) = getKOID(_EventParacmb(i).SelectedItem)
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.Dialog And i = 3 Then
                                    AktuellesEreignis.Parameter(i) = _EventParacmb(i).Text
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.EinheitenSpawn And i = 0 Then
                                    AktuellesEreignis.Parameter(i) = getUnitID(_EventParacmb(i).SelectedItem)
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.EinheitenSpawn And i = 5 Then
                                    AktuellesEreignis.Parameter(i) = _EventParacmb(i).SelectedItem
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.Gewonnen Or AktuellesEreignis.Ereignisart = Ereignisarten.NeutralerGebäudeAngriff Then
                                    AktuellesEreignis.Parameter(i) = _EventParacmb(i).SelectedItem
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.landkarte Then
                                    AktuellesEreignis.Parameter(i) = getLandkarteID(_EventParacmb(i).SelectedItem)
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.RemoveBlockierteEinheit And i = 0 Then
                                    AktuellesEreignis.Parameter(i) = getUnitID(_EventParacmb(i).SelectedItem)
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.RemoveBlockierteEinheit And i = 1 Then
                                    AktuellesEreignis.Parameter(i) = getArmeeID(_EventParacmb(i).SelectedItem)
                                    Continue For
                                ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.SetKO And i = 2 Then
                                    AktuellesEreignis.Parameter(i) = getKOID(_EventParacmb(i).SelectedItem)
                                    Continue For
                                Else
                                    AktuellesEreignis.Parameter(i) = _EventParacmb(i).SelectedIndex
                                End If
                        End Select
                        'ein paar Außnahmen
                       


                    End If
                End If
            Next
        End If



        scripte(scInd).Ereignisse(scEventInd) = AktuellesEreignis

        lbScriptEvent.Items.RemoveAt(scEventInd)
        lbScriptEvent.Items.Insert(scEventInd, cmbScriptEventArt.SelectedItem)
        lbScriptEvent.SelectedIndex = scEventInd
    End Sub
    Sub SaveCustomCOEffect()
        If AktuellerCOEffekt Is Nothing Then Exit Sub
        Dim ID As String = AktuellerCOEffekt.ToString.Split(":")(0)
        Dim Value(4) As Object
        For I = 0 To 4
            If _COEffectsParacmb(I).Visible Then
                Value(I) = _COEffectsParacmb(I).SelectedIndex
            ElseIf _COEffectsParanum(I).Visible Then
                Value(I) = _COEffectsParanum(I).Value
            End If
        Next
        Select Case ID
            Case "Invasion"
                Dim Units() As String = {}
                For I = 0 To 6
                    If _COEffectsParacmb(I).SelectedItem <> "-" Then
                        Array.Resize(Units, Units.Length + 1)
                        Units(Units.Length - 1) = getUnitID(_COEffectsParacmb(I).SelectedItem)
                    End If
                Next
                AktuellerCOEffekt = KOCustom.Power.PowerScript.GetEffect(ID, Units, Nothing, Nothing, Nothing, Nothing)
            Case "Fallschrimspringer"
                If _COEffectsParacmb(0).SelectedItem <> "-" Then
                    Value(0) = getUnitID(_COEffectsParacmb(0).SelectedItem)
                End If
                Value(2) = _COEffectsParacmb(2).SelectedItem
                AktuellerCOEffekt = KOCustom.Power.PowerScript.GetEffect(ID, Value(0), Value(1), Value(2), Value(3), Value(4))
            Case Else
                AktuellerCOEffekt = KOCustom.Power.PowerScript.GetEffect(ID, Value(0), Value(1), Value(2), Value(3), Value(4))
        End Select
        If lbCustomEvents.SelectedIndex >= 0 Then
            CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects(lbCustomEvents.SelectedIndex) = AktuellerCOEffekt
        Else
            CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects(0) = AktuellerCOEffekt
        End If
        lbCustomEvents.Items.Clear()
        If CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects.Count > 0 Then
            For Each Effect In CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects
                lbCustomEvents.Items.Add(Effect.ToString.Split(":")(0))
            Next
        Else
            lbCustomEvents.Items.Add("Effects")
        End If

    End Sub

    Sub showCustomCOEffect()
        If AktuellerCOEffekt Is Nothing Then Exit Sub

        For i = 0 To 6
            _COEffectsParacmb(i).Visible = False
            _COEffectsParacmb(i).DropDownStyle = ComboBoxStyle.DropDownList
            _COEffectsParalbl(i).Visible = False
            _COEffectsParanum(i).Visible = False
            _COEffectsParanum(i).Minimum = 0
            _COEffectsParanum(i).Maximum = 9999999
            _COEffectsParanum(i).DecimalPlaces = 0
            _COEffectsParanum(i).Increment = 1
        Next
        'Effects setzen
        Select Case AktuellerCOEffekt.ToString.Split(":")(0)
            Case "BesetzungsRestart"
                'Nothing
            Case "HalbesGeld"
                'Nothing
            Case "HalbesEinkommen"
                'Nothing
            Case "KeinEinkommen"
                'Nothing
            Case "NeutralMachen"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Number of Cities going Neutral"
                _COEffectsParanum(0).Visible = True
            Case "NeutralesGeld"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Fonds you earn per Neutral City"
                _COEffectsParanum(0).Visible = True
            Case "Massenschaden"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Damage every Unit gets"
                _COEffectsParanum(0).Visible = True

                _COEffectsParalbl(1).Visible = True
                _COEffectsParalbl(1).Text = "Units that get damaged"
                _COEffectsParacmb(1).Visible = True
                _COEffectsParacmb(1).Items.Clear()
                _COEffectsParacmb(1).Items.AddRange([Enum].GetNames(KOCustom.Power.PowerScript.EffectMassDamage.DamageUnit.AllEnemies.GetType))
            Case "MassenschadenLähmung"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Damage every Unit gets"
                _COEffectsParanum(0).Visible = True

                _COEffectsParalbl(1).Visible = True
                _COEffectsParalbl(1).Text = "HP that a Unit has to have left so it can't move next turn."
                _COEffectsParacmb(1).Visible = True
            Case "Gebäudeerschaffen"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "The building that'll be created."
                _COEffectsParacmb(0).Visible = True
                _COEffectsParacmb(0).Items.Clear()
                For Each G In Objektverwalter.AlleGebäude
                    If Not G.SpezialGebäude Then
                        _COEffectsParacmb(0).Items.Add(G.GebäudeID)
                    End If
                Next
            Case "GebäudeNochmalSchießen"
                'Nothing
            Case "StadtÜbernehmen"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Number of Cities you'll get."
                _COEffectsParanum(0).Visible = True
            Case "gelderhöhen"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "This will be multiplied with your Fonds and tham added."
                _COEffectsParanum(0).Visible = True
                _COEffectsParanum(0).DecimalPlaces = 1
                _COEffectsParanum(0).Increment = 0.1
                _COEffectsParanum(0).Maximum = 10
            Case "Ration"
                'Nothing
            Case "Wetterändern"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "The new Weather."
                _COEffectsParacmb(0).Visible = True
                _COEffectsParacmb(0).Items.Clear()
                _COEffectsParacmb(0).Items.AddRange([Enum].GetNames(ObjektSpielfeld.Wetterarten.Regen.GetType))

                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "The time this weather will durate."
                _COEffectsParanum(0).Visible = True
            Case "Rakete"
                'Return New EffectRocket(Value1, Value2, Value3, Value4, Value5)
            Case "HeilenKOZone"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "All units in the CO-Zone will earn this HP."
                _COEffectsParanum(0).Visible = True
            Case "TreibMuniStehlen"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Steal Ammo 1=True."
                _COEffectsParanum(0).Visible = True
                _COEffectsParanum(0).Minimum = 0
                _COEffectsParanum(0).Maximum = 1

                _COEffectsParalbl(1).Visible = True
                _COEffectsParalbl(1).Text = "Steal Fuel 1=True."
                _COEffectsParanum(1).Visible = True
                _COEffectsParanum(1).Minimum = 0
                _COEffectsParanum(1).Maximum = 1
            Case "NochmalZiehen"
                'Nothing
            Case "StadtBauen"
                'Nothing
            Case "HöhereBewegungskosten"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "All enemy troops will need more Movement Points."
                _COEffectsParanum(0).Visible = True
            Case "Zusatzangriffe"
                'Nothing
            Case "Schock"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "The percentage of enemy Units that'll be shocked."
                _COEffectsParanum(0).Visible = True
                _COEffectsParanum(0).Minimum = 0
                _COEffectsParanum(0).Maximum = 100
            Case "Invasion"
                _COEffectsParalbl(1).Visible = True
                _COEffectsParalbl(1).Text = "Unit that'll be spawned."
                _COEffectsParacmb(1).Visible = True
                _COEffectsParacmb(1).Items.Clear()
                _COEffectsParacmb(1).Items.Add("-")
                _COEffectsParacmb(1).Items.AddRange(UnitÜbersetzt)

                _COEffectsParalbl(2).Visible = True
                _COEffectsParalbl(2).Text = "Unit that'll be spawned."
                _COEffectsParacmb(2).Visible = True
                _COEffectsParacmb(2).Items.Clear()
                _COEffectsParacmb(2).Items.Add("-")
                _COEffectsParacmb(2).Items.AddRange(UnitÜbersetzt)

                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Unit that'll be spawned."
                _COEffectsParacmb(0).Visible = True
                _COEffectsParacmb(0).Items.Clear()
                _COEffectsParacmb(0).Items.Add("-")
                _COEffectsParacmb(0).Items.AddRange(UnitÜbersetzt)

                _COEffectsParalbl(3).Visible = True
                _COEffectsParalbl(3).Text = "Unit that'll be spawned."
                _COEffectsParacmb(3).Visible = True
                _COEffectsParacmb(3).Items.Clear()
                _COEffectsParacmb(3).Items.Add("-")
                _COEffectsParacmb(3).Items.AddRange(UnitÜbersetzt)

                _COEffectsParalbl(4).Visible = True
                _COEffectsParalbl(4).Text = "Unit that'll be spawned."
                _COEffectsParacmb(4).Visible = True
                _COEffectsParacmb(4).Items.Clear()
                _COEffectsParacmb(4).Items.Add("-")
                _COEffectsParacmb(4).Items.AddRange(UnitÜbersetzt)

                _COEffectsParalbl(5).Visible = True
                _COEffectsParalbl(5).Text = "Unit that'll be spawned."
                _COEffectsParacmb(5).Visible = True
                _COEffectsParacmb(5).Items.Clear()
                _COEffectsParacmb(5).Items.Add("-")
                _COEffectsParacmb(5).Items.AddRange(UnitÜbersetzt)

                _COEffectsParalbl(6).Visible = True
                _COEffectsParalbl(6).Text = "Unit that'll be spawned."
                _COEffectsParacmb(6).Visible = True
                _COEffectsParacmb(6).Items.Clear()
                _COEffectsParacmb(6).Items.Add("-")
                _COEffectsParacmb(6).Items.AddRange(UnitÜbersetzt)
            Case "KeinTruppenbau"
                'Nothing
            Case "KeineRation"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "So long all enemies can't get resupplied."
                _COEffectsParanum(0).Visible = True
            Case "AndereDeckung"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "The enemy deffence stars are multiplied with this value."
                _COEffectsParanum(0).Visible = True
                _COEffectsParanum(0).DecimalPlaces = 1
                _COEffectsParanum(0).Increment = 0.1
                _COEffectsParanum(0).Minimum = -1
                _COEffectsParanum(0).Maximum = 1
            Case "Gabenraub"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Steals enemy CO-Power depending on your Fonds and this value."
                _COEffectsParanum(0).Visible = True
            Case "Fallschrimspringer"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Unit that'll be spawned."
                _COEffectsParacmb(0).Visible = True
                _COEffectsParacmb(0).Items.Clear()
                _COEffectsParacmb(0).Items.Add("-")
                _COEffectsParacmb(0).Items.AddRange(UnitÜbersetzt)

                _COEffectsParalbl(1).Visible = True
                _COEffectsParalbl(1).Text = "The life points those units have."
                _COEffectsParanum(1).Visible = True

                _COEffectsParalbl(2).Visible = True
                _COEffectsParalbl(2).Text = "Animation that'll be shown."
                _COEffectsParacmb(2).Visible = True
                _COEffectsParacmb(2).Items.Clear()
                _COEffectsParacmb(2).Items.AddRange(New String() {"AndyGABE", "EagleGABE", "SenseiGABE"})
            Case "Besetzungsniedergang"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "All enemy buildings will loose these capture points for one round+you'll earn Fonds."
                _COEffectsParanum(0).Visible = True
            Case "Geldheilung"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "ATK-Boost you'll earn for each HP that can't be healed."
                _COEffectsParanum(0).Visible = True

                _COEffectsParalbl(1).Visible = True
                _COEffectsParalbl(1).Text = "Number of HP you'll get back."
                _COEffectsParanum(1).Visible = True
            Case "Lebensabrundung"
                'Nothing
            Case "KeinTPSehungEigene"
                'Nothing
            Case "KeinTPSehungFeinde"
                'Nothing
            Case "NoEnemyLifePoints"
                'Nothing
            Case "KeinGabeeinsatz"
                'Nothing
            Case "ActivateKriegsnebel"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Foq of War appears for so long."
                _COEffectsParanum(0).Visible = True
            Case "SetEnemyVisionRange"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "Enemy Vision range is set to this."
                _COEffectsParanum(0).Visible = True
                _COEffectsParanum(0).Minimum = 1
            Case "SetEnemyLuckAndCurse"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "New Enemy luck."
                _COEffectsParanum(0).Visible = True
                _COEffectsParanum(0).Minimum = Integer.MinValue
                _COEffectsParanum(0).Maximum = Integer.MinValue

                _COEffectsParalbl(1).Visible = True
                _COEffectsParalbl(1).Text = "New Enemy Curse."
                _COEffectsParanum(1).Visible = True
                _COEffectsParanum(1).Minimum = Integer.MinValue
                _COEffectsParanum(1).Maximum = Integer.MinValue
            Case "KeinGabeleisteAuffüllung"
                'nothing
            Case "WenigerEinahmendurchBesetzungszahl"
                _COEffectsParalbl(0).Visible = True
                _COEffectsParalbl(0).Text = "You'll earn Money the less capture points enemy buildings have."
                _COEffectsParanum(0).Visible = True
                _COEffectsParanum(0).DecimalPlaces = 2
                _COEffectsParanum(0).Increment = 0.05
                _COEffectsParanum(0).Minimum = 0
                _COEffectsParanum(0).Maximum = 1
        End Select
        For Each CB In _COEffectsParacmb
            If CB.Visible = True Then
                If CB.Items.Count > 0 Then
                    CB.SelectedIndex = 0
                End If
            End If
        Next
    End Sub
    Sub showEreignisse()
        If AktuellesEreignis Is Nothing Then Exit Sub

        lblScriptEventTipp.Text = getEventTipp(AktuellesEreignis.Ereignisart.ToString)
        dgvScriptDialog.Visible = False
        For i = 0 To 6
            _EventParacmb(i).DropDownStyle = ComboBoxStyle.DropDownList
            _EventParacmb(i).Visible = False
            _EventParalbl(i).Visible = False
            _EventParanum(i).Visible = False
            _EventParanum(i).Minimum = 0
            _EventParanum(i).Maximum = 9999999
            _EventParacmb(i).Size = _condParacmb(i).Size
            _EventParacmb(i).DropDownStyle = ComboBoxStyle.DropDownList
            ' _EventParanum(i).Left = _condParanum(0).Location.X
            ' _EventParacmb(i).Left = _condParanum(0).Location.X
        Next
        _EventParacmb(2).Size = _EventParacmb(0).Size
        Select Case AktuellesEreignis.Ereignisart
            Case Ereignisarten.Besiegt
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Player"
                _EventParanum(0).Visible = True
                _EventParanum(0).Minimum = 1
            Case Ereignisarten.AddWarteEinheit
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "X"
                _EventParanum(0).Visible = True

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Y"
                _EventParanum(1).Visible = True

                _EventParalbl(2).Visible = True
                _EventParalbl(2).Text = "Player"
                _EventParanum(2).Visible = True
                _EventParanum(2).Minimum = 1

                _EventParalbl(3).Visible = True
                _EventParalbl(3).Text = "Battlefield"
                _EventParacmb(3).Visible = True
                SetCmbSchlachtfelder(_EventParacmb(3).Items)


            Case Ereignisarten.Dialog
                dgvScriptDialog.Visible = True
                setScriptDialog(AktuellesEreignis)
                Exit Sub
                '_EventParalbl(0).Visible = True
                '_EventParalbl(0).Text = "KO"
                '_EventParacmb(0).Visible = True
                'SetCmbKO(_EventParacmb(0).Items, False)

                '_EventParalbl(1).Visible = True
                '_EventParalbl(1).Text = "Player"
                '_EventParanum(1).Visible = True
                '_EventParanum(1).Minimum = 1

                '_EventParalbl(2).Visible = True
                '_EventParalbl(2).Text = "facial expression"
                '_EventParacmb(2).Visible = True
                'SetCmbGesichtsausdruck(_EventParacmb(2).Items)

                '_EventParalbl(3).Visible = True
                '_EventParalbl(3).Text = ""
                '_EventParacmb(3).Visible = True
                '_EventParacmb(3).DropDownStyle = ComboBoxStyle.Simple
                '_EventParacmb(3).Size = New Size(2000, _EventParacmb(3).Height)


            Case Ereignisarten.EinheitenSpawn
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Unit"
                _EventParacmb(0).Visible = True
                SetCmbUnits(_EventParacmb(0).Items)

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "X"
                _EventParanum(1).Visible = True

                _EventParalbl(2).Visible = True
                _EventParalbl(2).Text = "Y"
                _EventParanum(2).Visible = True

                _EventParalbl(3).Visible = True
                _EventParalbl(3).Text = "Player"
                _EventParanum(3).Visible = True
                _EventParanum(3).Minimum = 1

                _EventParalbl(4).Visible = True
                _EventParalbl(4).Text = "Live"
                _EventParanum(4).Visible = True

                _EventParalbl(5).Visible = True
                _EventParalbl(5).Text = "can move"
                _EventParacmb(5).Visible = True
                SetCmbBoolean(_EventParacmb(5).Items)

                _EventParalbl(6).Visible = True
                _EventParalbl(6).Text = "Battlefield"
                _EventParacmb(6).Visible = True
                SetCmbSchlachtfelder(_EventParacmb(6).Items)


            Case Ereignisarten.Gewonnen
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Team"
                _EventParacmb(0).Visible = True
                SetCmbTeams(_EventParacmb(0).Items)


            Case Ereignisarten.landkarte
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Status"
                _EventParacmb(0).Visible = True
                SetCmbLandkarte(_EventParacmb(0).Items)
                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Mission index"
                _EventParanum(1).Visible = True


            Case Ereignisarten.NeutralerGebäudeAngriff
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Player"
                _EventParanum(0).Visible = True
                _EventParanum(0).Minimum = 1

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "attack"
                _EventParacmb(1).Visible = True
                SetCmbBoolean(_EventParacmb(1).Items)


            Case Ereignisarten.RemoveBlockierteEinheit
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Unit"
                _EventParacmb(0).Visible = True
                SetCmbUnits(_EventParacmb(0).Items)

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "army"
                _EventParacmb(1).Visible = True
                SetCmbArmeen(_EventParacmb(1).Items)


            Case Ereignisarten.Schadenswelle
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Player"
                _EventParanum(0).Visible = True
                _EventParanum(0).Minimum = 1

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Damage"
                _EventParanum(1).Visible = True


            Case Ereignisarten.setFabrikFonds
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "X"
                _EventParanum(0).Visible = True

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Y"
                _EventParanum(1).Visible = True

                _EventParalbl(2).Visible = True
                _EventParalbl(2).Text = "Fonds"
                _EventParanum(2).Visible = True


            Case Ereignisarten.SetFeuerladung
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "X"
                _EventParanum(0).Visible = True

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Y"
                _EventParanum(1).Visible = True

                _EventParalbl(2).Visible = True
                _EventParalbl(2).Text = "Days until can Fire"
                _EventParanum(2).Visible = True

                _EventParalbl(3).Visible = True
                _EventParalbl(3).Text = "Battlefield"
                _EventParacmb(3).Visible = True
                SetCmbSchlachtfelder(_EventParacmb(3).Items)


            Case Ereignisarten.SetKO
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Player"
                _EventParanum(0).Visible = True
                _EventParanum(0).Minimum = 1

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Index"
                _EventParacmb(1).Visible = True
                SetCmbKOInd(_EventParacmb(1).Items)

                _EventParalbl(2).Visible = True
                _EventParalbl(2).Text = "KO"
                _EventParacmb(2).Visible = True
                SetCmbKO(_EventParacmb(2).Items, True)


            Case Ereignisarten.SetKP
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "X"
                _EventParanum(0).Visible = True

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Y"
                _EventParanum(1).Visible = True

                _EventParalbl(2).Visible = True
                _EventParalbl(2).Text = "KP - Live(1-10)"
                _EventParanum(2).Visible = True

                _EventParalbl(3).Visible = True
                _EventParalbl(3).Text = "Battlefield"
                _EventParacmb(3).Visible = True
                SetCmbSchlachtfelder(_EventParacmb(3).Items)
            Case Ereignisarten.NewVariable
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Variable Name"
                _EventParacmb(0).Visible = True
                _EventParacmb(0).DropDownStyle = ComboBoxStyle.Simple

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Start Value"
                _EventParanum(1).Visible = True
                _EventParanum(1).Minimum = Integer.MinValue
                _EventParanum(1).Maximum = Integer.MaxValue
            Case Ereignisarten.SetVariable
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Variable Name"
                _EventParacmb(0).Visible = True
                _EventParacmb(0).DropDownStyle = ComboBoxStyle.Simple

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "New Value"
                _EventParanum(1).Visible = True
                _EventParanum(1).Minimum = Integer.MinValue
                _EventParanum(1).Maximum = Integer.MaxValue
            Case Ereignisarten.IncreaseVariable
                _EventParalbl(0).Visible = True
                _EventParalbl(0).Text = "Variable Name"
                _EventParacmb(0).Visible = True
                _EventParacmb(0).DropDownStyle = ComboBoxStyle.Simple

                _EventParalbl(1).Visible = True
                _EventParalbl(1).Text = "Value which will be added"
                _EventParanum(1).Visible = True
                _EventParanum(1).Minimum = Integer.MinValue
                _EventParanum(1).Maximum = Integer.MaxValue
        End Select

        For i = 0 To 6
            If _EventParalbl(i).Visible Then
                'Den Parameter gibt's
                If _EventParanum(i).Visible Then
                    'eine Zahl!
                    _EventParanum(i).Value = AktuellesEreignis.Parameter(i)
                Else
                    'eine Combobox!
                    If AktuellesEreignis.Parameter(i).ToUpper = "TRUE" Or AktuellesEreignis.Parameter(i).ToUpper = "FALSE" Then
                        AktuellesEreignis.Parameter(i) = AktuellesEreignis.Parameter(i).ToUpper
                    End If
                    'ein paar Außnahmen
                    Select Case AktuellesEreignis.Ereignisart
                        Case Ereignisarten.SetVariable
                            _EventParacmb(i).Text = AktuellesEreignis.Parameter(i)
                        Case Ereignisarten.NewVariable
                            _EventParacmb(i).Text = AktuellesEreignis.Parameter(i)
                        Case Ereignisarten.IncreaseVariable
                            _EventParacmb(i).Text = AktuellesEreignis.Parameter(i)
                        Case Else
                            If AktuellesEreignis.Ereignisart = Ereignisarten.Dialog And i = 0 Then
                                _EventParacmb(i).SelectedItem = getKOString(AktuellesEreignis.Parameter(i))
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.Dialog And i = 3 Then
                                _EventParacmb(i).Text = AktuellesEreignis.Parameter(i)
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.EinheitenSpawn And i = 0 Then
                                _EventParacmb(i).SelectedItem = getUnitString(AktuellesEreignis.Parameter(i))
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.EinheitenSpawn And i = 5 Then
                                _EventParacmb(i).SelectedItem = AktuellesEreignis.Parameter(i)
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.Gewonnen Or AktuellesEreignis.Ereignisart = Ereignisarten.NeutralerGebäudeAngriff Then
                                _EventParacmb(i).SelectedItem = AktuellesEreignis.Parameter(i)
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.landkarte Then
                                _EventParacmb(i).SelectedItem = getLandkarteStr(AktuellesEreignis.Parameter(i))
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.RemoveBlockierteEinheit And i = 0 Then
                                _EventParacmb(i).SelectedItem = getUnitString(AktuellesEreignis.Parameter(i))
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.RemoveBlockierteEinheit And i = 1 Then
                                _EventParacmb(i).SelectedItem = getArmeString(AktuellesEreignis.Parameter(i))
                                Continue For
                            ElseIf AktuellesEreignis.Ereignisart = Ereignisarten.SetKO And i = 2 Then
                                _EventParacmb(i).SelectedItem = getKOString(AktuellesEreignis.Parameter(i))
                                Continue For
                            Else
                                _EventParacmb(i).SelectedIndex = AktuellesEreignis.Parameter(i)
                            End If
                    End Select
                End If
            End If
        Next
    End Sub
    Sub showBedingungen()
        If AktuelleBedingung Is Nothing Then Exit Sub


        lblScriptCondTipp.Text = getConditionTipp(AktuelleBedingung.Bedingungsart.ToString)

        For i = 0 To 6
            _condParacmb(i).Visible = False
            _condParacmb(i).DropDownStyle = ComboBoxStyle.DropDownList
            _condParalbl(i).Visible = False
            _condParanum(i).Visible = False
            _condParanum(i).Minimum = 0
            _condParanum(i).Maximum = 9999999
        Next

        Select Case AktuelleBedingung.Bedingungsart
            Case Bedingungsarten.Besetzt
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "X"

                _condParalbl(1).Visible = True
                _condParanum(1).Visible = True
                _condParalbl(1).Text = "Y"

                _condParalbl(2).Visible = True
                _condParanum(2).Visible = True
                _condParanum(2).Minimum = 1
                _condParalbl(2).Text = "player"

                _condParalbl(3).Visible = True
                _condParacmb(3).Visible = True
                _condParalbl(3).Text = "Battlefield"
                SetCmbSchlachtfelder(_condParacmb(3).Items)
            Case Bedingungsarten.CountLandkarteZustand
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "start map"

                _condParalbl(1).Visible = True
                _condParanum(1).Visible = True
                _condParalbl(1).Text = "end map"

                _condParalbl(2).Visible = True
                _condParanum(2).Visible = True
                _condParalbl(2).Text = "count"

                _condParalbl(3).Visible = True
                _condParacmb(3).Visible = True
                _condParalbl(3).Text = "status"
                SetCmbMissionszustände(_condParacmb(3).Items)
            Case Bedingungsarten.EinheitZerstört
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "X"

                _condParalbl(1).Visible = True
                _condParanum(1).Visible = True
                _condParalbl(1).Text = "Y"

                _condParalbl(2).Visible = True
                _condParacmb(2).Visible = True
                SetCmbSchlachtfelder(_condParacmb(2).Items)
                _condParalbl(2).Text = "Battlefield"
            Case Bedingungsarten.FeldLeer
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "X"

                _condParalbl(1).Visible = True
                _condParanum(1).Visible = True
                _condParalbl(1).Text = "Y"

                _condParalbl(2).Visible = True
                _condParacmb(2).Visible = True
                SetCmbSchlachtfelder(_condParacmb(2).Items)
                _condParalbl(2).Text = "Battlefield"
            Case Bedingungsarten.Feuerladung
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "X"

                _condParalbl(1).Visible = True
                _condParanum(1).Visible = True
                _condParalbl(1).Text = "Y"

                _condParalbl(2).Visible = True
                _condParanum(2).Visible = True
                _condParalbl(2).Text = "next ""Ka-Wumm"" in .. days (0=you can shoot)"

                _condParalbl(3).Visible = True
                _condParacmb(3).Visible = True
                SetCmbSchlachtfelder(_condParacmb(3).Items)
                _condParalbl(3).Text = "Battlefield"
            Case Bedingungsarten.GebäudeZerstört
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "X"

                _condParalbl(1).Visible = True
                _condParanum(1).Visible = True
                _condParalbl(1).Text = "Y"

                _condParalbl(2).Visible = True
                _condParacmb(2).Visible = True
                SetCmbSchlachtfelder(_condParacmb(2).Items)
                _condParalbl(2).Text = "Battlefield"
            Case Bedingungsarten.InBereich
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "X: Left"

                _condParalbl(1).Visible = True
                _condParanum(1).Visible = True
                _condParalbl(1).Text = "Y: Top"

                _condParalbl(2).Visible = True
                _condParanum(2).Visible = True
                _condParalbl(2).Text = "X: Right"

                _condParalbl(3).Visible = True
                _condParanum(3).Visible = True
                _condParalbl(3).Text = "Y: Bottom"

                _condParalbl(4).Visible = True
                _condParacmb(4).Visible = True
                SetCmbSchlachtfelder(_condParacmb(4).Items)
                _condParalbl(4).Text = "Battlefield"

                _condParalbl(5).Visible = True
                _condParanum(5).Visible = True
                _condParalbl(5).Text = "Player"
                _condParanum(5).Minimum = 1
            Case Bedingungsarten.LandkartenZustand
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "map"

                _condParalbl(1).Visible = True
                _condParacmb(1).Visible = True
                _condParalbl(1).Text = "status"
                SetCmbMissionszustände(_condParacmb(1).Items)
            Case Bedingungsarten.Sieg
                _condParalbl(0).Visible = True
                _condParacmb(0).Visible = True
                _condParalbl(0).Text = "Team"
                SetCmbTeams(_condParacmb(0).Items)
            Case Bedingungsarten.SpielerBesiegt
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "Player"
                _condParanum(0).Minimum = 1
            Case Bedingungsarten.TagGleich
                _condParalbl(0).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(2).Visible = True
                _condParanum(0).Visible = True
                _condParacmb(1).Visible = True
                _condParanum(2).Visible = True
                SetCmbPrüfstadien(_condParacmb(1).Items)
                _condParalbl(0).Text = "Day"
                _condParalbl(1).Text = " "
                _condParalbl(2).Text = "Player"
                _condParanum(2).Minimum = 1
            Case Bedingungsarten.TagGrößer
                _condParalbl(0).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(2).Visible = True
                _condParanum(0).Visible = True
                _condParacmb(1).Visible = True
                _condParanum(2).Visible = True
                SetCmbPrüfstadien(_condParacmb(1).Items)
                _condParalbl(0).Text = "Day"
                _condParalbl(1).Text = " "
                _condParalbl(2).Text = "Player"
                _condParanum(2).Minimum = 1
            Case Bedingungsarten.TagKleiner
                _condParalbl(0).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(2).Visible = True
                _condParanum(0).Visible = True
                _condParacmb(1).Visible = True
                _condParanum(2).Visible = True
                SetCmbPrüfstadien(_condParacmb(1).Items)
                _condParalbl(0).Text = "Day"
                _condParalbl(1).Text = " "
                _condParalbl(2).Text = "Player"
                _condParanum(2).Minimum = 1
            Case Bedingungsarten.TagMal
                _condParalbl(0).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(2).Visible = True
                _condParanum(0).Visible = True
                _condParacmb(1).Visible = True
                _condParanum(2).Visible = True
                SetCmbPrüfstadien(_condParacmb(1).Items)
                _condParalbl(0).Text = "Day"
                _condParalbl(1).Text = " "
                _condParalbl(2).Text = "Player"
                _condParanum(2).Minimum = 1
            Case Bedingungsarten.TagMalImmer
                _condParalbl(0).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(2).Visible = True
                _condParanum(0).Visible = True
                _condParacmb(2).Visible = True
                _condParanum(1).Visible = True
                _condParanum(1).Minimum = -10
                SetCmbPrüfstadien(_condParacmb(2).Items)
                _condParalbl(0).Text = "Day"
                _condParalbl(1).Text = "Start Day"
                _condParalbl(2).Text = ""
            Case Bedingungsarten.Zufall
                _condParalbl(0).Visible = True
                _condParanum(0).Visible = True
                _condParalbl(0).Text = "%"
                _condParanum(2).Maximum = 100
            Case Bedingungsarten.VariableGleich
                _condParalbl(0).Visible = True
                _condParacmb(0).Visible = True
                _condParacmb(0).Items.Clear()
                _condParacmb(0).DropDownStyle = ComboBoxStyle.DropDown
                _condParalbl(0).Text = "The Variable Name"

                _condParanum(1).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(1).Text = "A Variable has to be equal to"
                _condParanum(1).Minimum = Integer.MinValue
                _condParanum(1).Maximum = Integer.MaxValue
            Case Bedingungsarten.VariableKleiner
                _condParalbl(0).Visible = True
                _condParacmb(0).Visible = True
                _condParacmb(0).Items.Clear()
                _condParacmb(0).DropDownStyle = ComboBoxStyle.DropDown
                _condParalbl(0).Text = "The Variable Name"

                _condParanum(1).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(1).Text = "A Variable has to be smaller than"
                _condParanum(1).Minimum = Integer.MinValue
                _condParanum(1).Maximum = Integer.MaxValue
            Case Bedingungsarten.VariableGrößer
                _condParalbl(0).Visible = True
                _condParacmb(0).Visible = True
                _condParacmb(0).Items.Clear()
                _condParacmb(0).DropDownStyle = ComboBoxStyle.DropDown
                _condParalbl(0).Text = "The Variable Name"

                _condParanum(1).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(1).Text = "A Variable has to be greater than"
                _condParanum(1).Minimum = Integer.MinValue
                _condParanum(1).Maximum = Integer.MaxValue
            Case Bedingungsarten.VariableGrößerGleich
                _condParalbl(0).Visible = True
                _condParacmb(0).Visible = True
                _condParacmb(0).Items.Clear()
                _condParacmb(0).DropDownStyle = ComboBoxStyle.DropDown
                _condParalbl(0).Text = "A Variable has to be equal or greater than"

                _condParanum(1).Visible = True
                _condParalbl(1).Visible = True
                _condParalbl(1).Text = "The Variable Name"
                _condParanum(1).Minimum = Integer.MinValue
                _condParanum(1).Maximum = Integer.MaxValue
        End Select
        For i = 0 To 6
            If _condParalbl(i).Visible Then
                'Den Parameter gibt's
                If _condParanum(i).Visible Then
                    'eine Zahl!
                    _condParanum(i).Value = AktuelleBedingung.Parameter(i)

                Else
                    'eine Combobox!
                    If AktuelleBedingung.Parameter(i).ToUpper = "TRUE" Or AktuelleBedingung.Parameter(i).ToUpper = "FALSE" Then
                        AktuelleBedingung.Parameter(i) = AktuelleBedingung.Parameter(i).ToUpper
                    End If


                    If AktuelleBedingung.Bedingungsart = Bedingungsarten.Sieg Then
                        _condParacmb(i).SelectedItem = AktuelleBedingung.Parameter(i)
                    Else
                        If IsNumeric(AktuelleBedingung.Parameter(i)) Then
                            _condParacmb(i).SelectedIndex = AktuelleBedingung.Parameter(i)
                        Else
                            _condParacmb(i).Text = AktuelleBedingung.Parameter(i)
                        End If
                    End If
                End If
            End If
        Next

    End Sub

    Sub SetCmbPrüfstadien(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        Item.Add("Beginning of the day")
        Item.Add("during the day")
        Item.Add("End of the day")
    End Sub
    Sub SetCmbSchlachtfelder(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        Item.Add("Ground Battle")
        Item.Add("Air Battle")
    End Sub
    Sub SetCmbMissionszustände(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        Item.Add("not choosable")
        Item.Add("choosable")
        Item.Add("Fokused")
        Item.Add("Won")
        Item.Add("Lost")
    End Sub
    Sub SetCmbLandkarte(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        For i = 0 To MissionsstatusÜbersetzt.Length - 1
            Item.Add(MissionsstatusÜbersetzt(i))
        Next
    End Sub
    Sub SetCmbTeams(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        Item.Add("A")
        Item.Add("B")
        Item.Add("C")
        Item.Add("D")
        Item.Add("E")
        Item.Add("F")
        Item.Add("G")
        Item.Add("H")
        Item.Add("I")
        Item.Add("J")
        Item.Add("K")
        Item.Add("L")
        Item.Add("M")
        Item.Add("N")
        Item.Add("O")
        Item.Add("P")
        Item.Add("Q")
        Item.Add("R")
        Item.Add("S")
        Item.Add("T")
        Item.Add("U")
        Item.Add("V")
        Item.Add("W")
        Item.Add("X")
        Item.Add("Y")
        Item.Add("Z")
    End Sub
    Sub SetCmbUnits(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        For i = 0 To UnitÜbersetzt.Length - 1
            Item.Add(UnitÜbersetzt(i))
        Next
    End Sub
    Sub SetCmbBoolean(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        Item.Add("FALSE")
        Item.Add("TRUE")
    End Sub
    Sub SetCmbKOInd(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        Item.Add("first KO")
        Item.Add("secound KO")
    End Sub
    Sub SetCmbKO(ByRef Item As ComboBox.ObjectCollection, ByVal NoOne As Boolean)
        Item.Clear()
        If NoOne Then Item.Add("-")
        For i = 0 To KOÜbersetzt.Length - 1
            Item.Add(KOÜbersetzt(i))
        Next
    End Sub
    Sub SetCmbGesichtsausdruck(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        Item.Add("Normal")
        Item.Add("Happy")
        Item.Add("Sad")
    End Sub
    Sub SetCmbFarbtabellen(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        For i = 0 To FarbtabellenÜbersetzt.Length - 1
            Item.Add(FarbtabellenÜbersetzt(i))
        Next
    End Sub
    Sub SetCmbArmeen(ByRef Item As ComboBox.ObjectCollection)
        Item.Clear()
        For i = 0 To ArmeeÜbersetzt.Length - 1
            Item.Add(ArmeeÜbersetzt(i))
        Next
    End Sub

    ''' <summary>
    ''' Fürgt eine neue DialogZeile ein.
    ''' </summary>
    ''' <param name="dgv"></param>
    ''' <param name="KOID"></param>
    ''' <param name="spieler">bei 1 beginnend für OS</param>
    ''' <param name="Gesichtsausdruck"></param>
    ''' <param name="Text">entweder der Text, aber auch %Language% möglich</param>
    ''' <remarks></remarks>
    Sub AddRowDialog(ByVal dgv As DataGridView, ByVal SprKonv As DialogTextSprachKonverter, ByVal KOID As String, ByVal spieler As Integer, ByVal Gesichtsausdruck As Integer, ByVal Text As String)
        If Text.ToLower.Trim.StartsWith("%Language%".ToLower.Trim) Then
            Dim TextID As Integer = Text.Split("%")(2)
            AddRowDialog(dgv, KOID, spieler, Gesichtsausdruck, SprKonv.getText("English", TextID), SprKonv.getText("Deutsch", TextID), "", "")
        Else
            'Naja wenn ich nur einen Text habe, dann ist der lieber im Englischen wie im Deutschen gleich, als wenn da jetzt in dem einen nix steht. (Dann doch lieber Fremdsprache)
            AddRowDialog(dgv, KOID, spieler, Gesichtsausdruck, Text, Text, "", "")
        End If
    End Sub
    Sub AddRowDialog(ByVal dgv As DataGridView, ByVal SprKonv As DialogTextSprachKonverter, ByVal KOID As String, ByVal spieler As Integer, ByVal Gesichtsausdruck As Integer, ByVal Musikpfad As String, ByVal Bildpfad As String, ByVal Text As String)
        If Text.ToLower.Trim.StartsWith("%Language%".ToLower.Trim) Then
            Dim TextID As Integer = Text.Split("%")(2)
            AddRowDialog(dgv, KOID, spieler, Gesichtsausdruck, SprKonv.getText("English", TextID), SprKonv.getText("Deutsch", TextID), Musikpfad, Bildpfad)
        Else
            'Naja wenn ich nur einen Text habe, dann ist der lieber im Englischen wie im Deutschen gleich, als wenn da jetzt in dem einen nix steht. (Dann doch lieber Fremdsprache)
            AddRowDialog(dgv, KOID, spieler, Gesichtsausdruck, Text, Text, Musikpfad, Bildpfad)
        End If
    End Sub
    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="dgv"></param>
    ''' <param name="KOID"></param>
    ''' <param name="spieler">bei 1 beginnend für OS</param>
    ''' <param name="Gesichtsausdruck"></param>
    ''' <param name="English"></param>
    ''' <param name="Deutsch"></param>
    ''' <remarks></remarks>
    Sub AddRowDialog(ByVal dgv As DataGridView, ByVal KOID As String, ByVal spieler As Integer, ByVal Gesichtsausdruck As Integer, ByVal English As String, ByVal Deutsch As String, ByVal Musikpfad As String, ByVal Bildpfad As String)
        Dim KOInd As Integer = -1
        Dim SpielerInd As Integer = -1
        Dim GesichtsausdruckInd As Integer = -1
        Dim EnglishInd As Integer = -1
        Dim DeutschInd As Integer = -1
        Dim MusikInd As Integer = -1
        Dim BildInd As Integer = -1
        For i = 0 To dgv.Columns.Count - 1
            Select Case dgv.Columns(i).HeaderText.ToLower
                Case "co"
                    KOInd = i
                Case "facial expression"
                    GesichtsausdruckInd = i
                Case "colour"
                    SpielerInd = i
                Case "english"
                    EnglishInd = i
                Case "deutsch"
                    DeutschInd = i
                Case "music style"
                    MusikInd = i
                Case "picture"
                    BildInd = i
            End Select
        Next
        If KOInd = -1 Or SpielerInd = -1 Or GesichtsausdruckInd = -1 Or EnglishInd = -1 Or DeutschInd = -1 Or MusikInd = -1 Or BildInd = -1 Then
            'Äh keine ahnung
            MsgBox("Error 007", MsgBoxStyle.Critical, "Error")
            Exit Sub
        End If
        Dim RInd As Integer = dgv.Rows.Add
        If KOID = "" Then KOID = "ANDY"
        dgv.Rows(RInd).Cells(KOInd).Value = getKOString(KOID)
        dgv.Rows(RInd).Cells(SpielerInd).Value = SpalteIniDialogFarbe.Items(spieler - 1)
        dgv.Rows(RInd).Cells(GesichtsausdruckInd).Value = SpalteIniDialogGesichtsausdruck.Items(Gesichtsausdruck)
        dgv.Rows(RInd).Cells(EnglishInd).Value = English
        dgv.Rows(RInd).Cells(DeutschInd).Value = Deutsch
        dgv.Rows(RInd).Cells(MusikInd).Value = Musikpfad
        dgv.Rows(RInd).Cells(BildInd).Value = Bildpfad
        dgv.Rows(RInd).Cells(MusikInd).Tag = "Custom"
    End Sub

    Sub setDefaultIni(ByVal Spieler As Boolean)
        cbLuftschlacht.Checked = True
        cbZufallswetter.Checked = False
        cbSofortStart.Checked = False
        cbPromotion.Checked = False

        txtScriptName.Text = ""
        txtNächsteKarte.Text = ""
        txtKartenname.Text = ""
        txtKartenbeschreibung.Text = ""
        dgvIniDialog.Rows.Clear()

        cmbKriegsnebel.SelectedIndex = 0
        cmbIniGameModus.SelectedIndex = 0

        SprachKonvIni = New DialogTextSprachKonverter

        cbSiegEinheiten.Checked = True
        cbSiegHQ.Checked = True
        If Spieler Then
            numSpieler.Value = 0
            numSpieler.Value = 2
        Else
            pSpielerdaten.Controls.Clear()
        End If
    End Sub

    Sub setKartenBeschreibung(ByVal Text As String)
        txtKartenbeschreibung.Text = Text.Replace("|", Environment.NewLine)
    End Sub

    Sub setScriptDialog(ByVal Ereignis As objEreignis)
        dgvScriptDialog.Rows.Clear()
        Do Until Ereignis Is Nothing
            Dim ri As Integer = dgvScriptDialog.Rows.Add(1)
            dgvScriptDialog(SpalteScriptDialogKO.Index, ri).Value = getKOString(Ereignis.Parameter(0))
            dgvScriptDialog(SpalteScriptDialogFarbe.Index, ri).Value = Ereignis.Parameter(1)
            Select Case Ereignis.Parameter(2)
                Case "1"
                    dgvScriptDialog(SpalteScriptDialogGesichtsausdruck.Index, ri).Value = "Happy"
                Case "2"
                    dgvScriptDialog(SpalteScriptDialogGesichtsausdruck.Index, ri).Value = "Sad"
                Case Else
                    dgvScriptDialog(SpalteScriptDialogGesichtsausdruck.Index, ri).Value = "Normal"
            End Select
            dgvScriptDialog(SpalteScriptDialogMusik.Index, ri).Value = Ereignis.Parameter(3)
            dgvScriptDialog(SpalteScriptDialogBild.Index, ri).Value = Ereignis.Parameter(4)
            Dim de As String = ""
            Dim en As String = ""
            If Ereignis.Parameter(5).ToLower.StartsWith("%Language%".ToLower) Then
                de = SprachKonvScript.getText("Deutsch", Ereignis.Parameter(5).Split("%")(2))
                en = SprachKonvScript.getText("English", Ereignis.Parameter(5).Split("%")(2))
                If de = "" Then de = en
                If en = "" Then en = de
            Else
                'vermutlich ein normaler Text.
                de = Ereignis.Parameter(5)
                en = Ereignis.Parameter(5)
            End If
            dgvScriptDialog(SpalteScriptDialogTextDeutsch.Index, ri).Value = de
            dgvScriptDialog(SpalteScriptDialogTextEnglish.Index, ri).Value = en

            Ereignis = Ereignis.folgeDialog
        Loop
    End Sub

    Sub CheckTextScriptFarbe()
        If txtScriptName.Text.Trim = "" Then
            txtScriptName.BackColor = Color.White
        Else
            If My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Scripts\" + txtScriptName.Text.Trim + ".script") Then
                txtScriptName.BackColor = Color.Lime
                scDateiname = My.Settings.Resourcenpfad + "Scripts\" + txtScriptName.Text.Trim + ".script"
                ScriptGeladen = False
            Else
                txtScriptName.BackColor = Color.Red
                ScriptGeladen = False
            End If
        End If
    End Sub
    Sub CheckTextCuIDFarbe()
        If txtCuID.Text.Trim = "" Then
            txtCuID.BackColor = Color.White
        Else
            If My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "!Custom\Unit\" + txtCuID.Text.Trim + ".ent") Then
                txtCuID.BackColor = Color.Lime
            Else
                txtCuID.BackColor = Color.Red
            End If
        End If
    End Sub
    Sub CheckLandkarteOrdnerFarbe()
        If My.Computer.FileSystem.DirectoryExists(OrdnernameLandkarte) Then
            btnLandkarteOrdner.BackColor = Color.Lime
            btnLandkarteOrdner.Font = txtCuID.Font
            btnLandkarteOrdner.Text = "change the campaign Folder"

            LandkartenName = OrdnernameLandkarte.Replace(".kamp", "")
            LandkartenName = LandkartenName.Remove(0, LandkartenName.LastIndexOf("\") + 1)
            'Jetzt werden (evtl.) nach ein paar Sachen gemacht.
            If txtLandkarteName.Text.Trim = "" Then
                txtLandkarteName.Text = LandkartenName
            End If
        Else
            btnLandkarteOrdner.BackColor = Color.Red
            btnLandkarteOrdner.Font = FontFett
            btnLandkarteOrdner.Text = "please select your Campaign Folder!"
            LandkartenName = ""
        End If
    End Sub

    'useful functions
    Function getKartenBeschreibung() As String
        Dim s As String = txtKartenbeschreibung.Text.Trim
        s = s.Replace(Environment.NewLine, "|")
        Return s
    End Function

    Function getKOString(ByVal ID As String)
        For i = 0 To KOID.Length - 1
            If KOID(i).ToUpper = ID.ToUpper Then Return KOÜbersetzt(i)
        Next
        Return ID
    End Function
    Function getKOID(ByVal Sprach As String) As String
        For i = 0 To KOID.Length - 1
            If KOÜbersetzt(i).ToUpper = Sprach.ToUpper Then Return KOID(i)
        Next
        Return Sprach
    End Function

    Function getConditionString(ByVal ID As String) As String
        For i = 0 To ConditionsID.Length - 1
            If ConditionsID(i).ToUpper = ID.ToUpper Then Return ConditionsÜbersetzt(i)
        Next
        Return ConditionsÜbersetzt(0)
    End Function
    Function getConditionID(ByVal Cond As String) As String
        For i = 0 To ConditionsID.Length - 1
            If ConditionsÜbersetzt(i).ToUpper = Cond.ToUpper Then Return ConditionsID(i)
        Next
        Return ConditionsID(0)
    End Function
    Function getConditionIndString(ByVal Str As String) As Integer
        For i = 0 To ConditionsÜbersetzt.Length - 1
            If ConditionsÜbersetzt(i).ToLower = Str.ToLower Then Return i
        Next
        Return 0
    End Function
    Function getConditionTipp(ByVal ID As String) As String
        For i = 0 To ConditionsID.Length - 1
            If ConditionsID(i).ToLower = ID.ToLower Then Return ConditionsTipp(i)
        Next
        Return ConditionsTipp(0)
    End Function

    Function getEventString(ByVal ID As String) As String
        For i = 0 To EventsID.Length - 1
            If EventsID(i).ToUpper = ID.ToUpper Then Return EventsÜbersetzt(i)
        Next
        Return EventsÜbersetzt(0)
    End Function
    Function getEventID(ByVal Ev As String) As String
        For i = 0 To EventsID.Length - 1
            If EventsÜbersetzt(i).ToUpper = Ev.ToUpper Then Return EventsID(i)
        Next
        Return EventsID(0)
    End Function
    Function getEventIndString(ByVal Str As String) As Integer
        For i = 0 To EventsÜbersetzt.Length - 1
            If EventsÜbersetzt(i).ToLower = Str.ToLower Then Return i
        Next
        Return 0
    End Function
    Function getEventTipp(ByVal ID As String) As String
        For i = 0 To EventsID.Length - 1
            If EventsID(i).ToLower = ID.ToLower Then Return EventsTipp(i)
        Next
        Return EventsTipp(0)
    End Function

    Function getUnitID(ByVal Str As String) As String
        For i = 0 To UnitID.Length - 1
            If UnitÜbersetzt(i).ToLower = Str.ToLower Then Return UnitID(i)
        Next
        Return UnitID(0)
    End Function
    Function getUnitString(ByVal ID As String) As String
        For i = 0 To UnitID.Length - 1
            If UnitID(i).ToLower = ID.ToLower Then Return UnitÜbersetzt(i)
        Next
        Return UnitÜbersetzt(0)
    End Function

    Function getFarbtabellenID(ByVal Str As String) As String
        For i = 0 To FarbtabellenID.Length - 1
            If FarbtabellenÜbersetzt(i).ToLower = Str.ToLower Then Return FarbtabellenID(i)
        Next
        Return FarbtabellenID(0)
    End Function
    Function getFarbtabellenString(ByVal ID As String) As String
        For i = 0 To FarbtabellenID.Length - 1
            If FarbtabellenID(i).ToLower = ID.ToLower Then Return FarbtabellenÜbersetzt(i)
        Next
        Return FarbtabellenÜbersetzt(0)
    End Function

    Function getLandkarteID(ByVal Str As String) As String
        For i = 0 To MissionsstatusÜbersetzt.Length - 1
            If MissionsstatusÜbersetzt(i).ToLower = Str.ToLower Then Return MissionsstatusID(i)
        Next
        Return MissionsstatusID(0)
    End Function
    Function getLandkarteStr(ByVal ID As String) As String
        For i = 0 To MissionsstatusID.Length - 1
            If MissionsstatusID(i).ToLower = ID.ToLower Then Return MissionsstatusÜbersetzt(i)
        Next
        Return MissionsstatusÜbersetzt(0)
    End Function

    Function getArmeeID(ByVal Str As String) As String
        For i = 0 To ArmeeID.Length - 1
            If ArmeeÜbersetzt(i).ToLower = Str.ToLower Then Return ArmeeID(i)
        Next
        Return ArmeeID(0)
    End Function
    Function getArmeString(ByVal ID As String) As String
        For i = 0 To ArmeeID.Length - 1
            If ArmeeID(i).ToLower = ID.ToLower Then Return ArmeeÜbersetzt(i)
        Next
        Return ArmeeÜbersetzt(0)
    End Function

    Function getFähigkID(ByVal Str As String) As String
        For i = 0 To SpezialFähigkID.Length - 1
            If SpezialFähigkÜbersetzt(i).ToLower = Str.ToLower Then Return SpezialFähigkID(i)
        Next
        Return SpezialFähigkID(0)
    End Function
    Function getFähigkString(ByVal ID As String) As String
        For i = 0 To SpezialFähigkID.Length - 1
            If SpezialFähigkID(i).ToLower = ID.ToLower Then Return SpezialFähigkÜbersetzt(i)
        Next
        Return SpezialFähigkÜbersetzt(0)
    End Function

    Function getBewegungskID(ByVal Str As String) As String
        For i = 0 To BewegungsartID.Length - 1
            If BewegungsartÜbersetzt(i).ToLower = Str.ToLower Then Return BewegungsartID(i)
        Next
        Return Str
    End Function
    Function getBewegungsString(ByVal ID As String) As String
        For i = 0 To BewegungsartID.Length - 1
            If BewegungsartID(i).ToLower = ID.ToLower Then Return BewegungsartÜbersetzt(i)
        Next
        Return ID
    End Function

    Function getWaffenID(ByVal Str As String) As String
        For i = 0 To WaffenID.Length - 1
            If WaffenÜbersetzt(i).ToLower = Str.ToLower Then Return WaffenID(i)
        Next
        Return Str
    End Function
    Function getWaffenString(ByVal ID As String) As String
        For i = 0 To WaffenID.Length - 1
            If WaffenID(i).ToLower = ID.ToLower Then Return WaffenÜbersetzt(i)
        Next
        Return ID
    End Function

    Function getLandschaftID(ByVal Str As String) As String
        For i = 0 To LandschaftID.Length - 1
            If LandschaftÜbersetzt(i).ToLower = Str.ToLower Then Return LandschaftID(i)
        Next
        Return Str
    End Function
    Function getLandschaftString(ByVal ID As String) As String
        For i = 0 To LandschaftID.Length - 1
            If LandschaftID(i).ToLower = ID.ToLower Then Return LandschaftÜbersetzt(i)
        Next
        Return ID
    End Function
    Function getEntladungsUntergrund() As String
        Dim Gebäude As String = ""
        For I = 0 To dgvCuLadungsUntergrund.Rows.Count - 1
            If dgvCuLadungsUntergrund(SpalteCuTerrainUntergrund.Index, I).Style.BackColor = Color.Lime Then
                Gebäude += getLandschaftID(dgvCuLadungsUntergrund(SpalteCuTerrainUntergrund.Index, I).Value.ToString) + "|"
            End If
        Next
        Gebäude = Gebäude.Remove(Gebäude.Length - 1)
        Return Gebäude
    End Function

    Function getEinheitenID(ByVal Str As String) As String
        For i = 0 To UnitID.Length - 1
            If UnitÜbersetzt(i).ToLower = Str.ToLower Then Return UnitID(i)
        Next
        Return Str
    End Function
    Function getEinheitenString(ByVal ID As String) As String
        For i = 0 To UnitID.Length - 1
            If UnitID(i).ToLower = ID.ToLower Then Return UnitÜbersetzt(i)
        Next
        Return ID
    End Function
    Function getGeladeneEinheiten() As String
        Dim Gebäude As String = ""
        For I = 0 To dgvCuGeladeneEinheiten.Rows.Count - 2
            If dgvCuGeladeneEinheiten(SpalteCuGeladeneEinheiten.Index, I).Style.BackColor = Color.Lime Then
                Gebäude += getEinheitenID(dgvCuGeladeneEinheiten(SpalteCuGeladeneEinheiten.Index, I).Value.ToString).ToUpper + "|"
            End If
        Next
        Gebäude = Gebäude.Remove(Gebäude.Length - 1)
        Return Gebäude
    End Function

    Function getExplosionID(ByVal Ex As String)
        Select Case Ex.ToLower
            Case "air"
                Return "Luft"
            Case "sea"
                Return "Wasser"
            Case Else
                Return "Land"
        End Select
    End Function
    Function getExplosionString(ByVal ID As String)
        Select Case ID.ToLower
            Case "Luft".ToLower
                Return "air"
            Case "Wasser".ToLower
                Return "sea"
            Case Else
                Return "land"
        End Select
    End Function

    Function getProduktionsGebäude() As String
        Dim Gebäude As String = ""
        For I = 0 To dgvCuProd.Rows.Count - 1
            If dgvCuProd(SpalteCuBauenErlauben.Index, I).Style.BackColor = Color.Lime Then
                Gebäude += getLandschaftID(dgvCuProd(SpalteCuBauenErlauben.Index, I).Value.ToString) + "|"
            End If
        Next
        If Gebäude.Length > 0 Then
            Gebäude = Gebäude.Remove(Gebäude.Length - 1)
        End If
        Return Gebäude
    End Function
    Function getGebäudeIdFromName(ByVal Name As String) As String
        Select Case Sprachconverter.TranslateIntoGerman(Name).ToLower
            Case "basis"
                Return "BASIS"
            Case "stadt"
                Return "STADT"
            Case "hauptquartier"
                Return "HQ"
            Case "Hafen"
                Return "WERFT"
            Case "flughafen"
                Return "FLUGHAFEN"
            Case "turm"
                Return "TURM"
            Case "labor"
                Return "LABOR"
            Case "mine"
                Return "MINE"
            Case "radar"
                Return "RADAR"
            Case "pipestation"
                Return "PIPESTATION"
            Case Else
                Return "BASIS"
        End Select
    End Function

    Function getArrayInd(ByVal Arr As DataGridViewComboBoxCell.ObjectCollection, ByVal Value As Object) As Integer
        For i = 0 To Arr.Count - 1
            If Arr(i) = Value Then Return i
        Next
        Return 0
    End Function

    Function Eingabenprüfen() As Boolean
        If cmbKriegsnebel.SelectedItem = "" Then
            If MsgBox("Invalid kind of Fog!" + Environment.NewLine + "Reset to: ""No Fog""?", MsgBoxStyle.OkCancel, "Invalid Input") = MsgBoxResult.Cancel Then Return False
            cmbKriegsnebel.SelectedItem = cmbKriegsnebel.Items(0)
        End If

        Return True
    End Function
    Function DialogPrüfen(ByVal dgv As DataGridView) As Boolean
        Return True


        Return False
    End Function


    Sub IniCustomCOEffect()
        Dim CB As ComboBox = cbCustomCOScript
        CB.Items.Clear()
        CB.Items.Add("Capture Restart")
        CB.Items.Add("Get Half Income")
        CB.Items.Add("Get Half Money")
        CB.Items.Add("No Income")
        CB.Items.Add("Make Neutral")
        CB.Items.Add("Get Neutral Money")
        CB.Items.Add("Mass Damage")
        CB.Items.Add("Mass Damage Move Stop")
        CB.Items.Add("Create Building")
        CB.Items.Add("Fire Again")
        CB.Items.Add("Get Enemy Building")
        CB.Items.Add("Increase Own Fonds")
        CB.Items.Add("Ration")
        CB.Items.Add("Rocket")
        CB.Items.Add("Heal CO Range")
        CB.Items.Add("Steal Ammo Fuel")
        CB.Items.Add("Move Again")
        CB.Items.Add("Town Production")
        CB.Items.Add("Increase Movement Costs")
        CB.Items.Add("Double Attack")
        CB.Items.Add("Shock Enemys")
        CB.Items.Add("No Production")
        CB.Items.Add("No Ration")
        CB.Items.Add("Other Deffence")
        CB.Items.Add("Steal Power")
        CB.Items.Add("Paratroopers")
        CB.Items.Add("Capture Down")
        CB.Items.Add("Moneyhealing")
        CB.Items.Add("Life Down")
        CB.Items.Add("No Own Life Points")
        CB.Items.Add("No Enemy Life Points")
        CB.Items.Add("No Power")
        CB.Items.Add("Active Fog Of War")
        CB.Items.Add("Set Enemy Vision Range")
        CB.Items.Add("Set Enemy Luck and Curse")
        CB.Items.Add("No Power Charge")
        CB.Items.Add("No Production")
        CB.Items.Add("Money For Capture Points")
        CB.Items.Add("Change Weather")
        CB.Items.Add("Invasion")
        CB.Items.Add("Only Infantry Attack")
        CB.SelectedIndex = 0

        _COEffectsParalbl(0) = lblCOScriptInfoLbl
        _COEffectsParanum(0) = numCOEffectInfo
        _COEffectsParanum(0).Minimum = 0
        _COEffectsParanum(0).Maximum = 9999999
        _COEffectsParacmb(0) = cbCOEffectInfo
        For I = 1 To 6
            Dim nlbl As New Label
            Dim nnum As New NumericUpDown
            Dim ncmb As New ComboBox
            nlbl.Text = "*" + (I + 1).ToString + "*:"
            nlbl.Left = _COEffectsParalbl(I - 1).Location.X
            nlbl.Top = _COEffectsParalbl(I - 1).Location.Y + ParamHöhe
            nlbl.Visible = _COEffectsParalbl(I - 1).Visible
            nlbl.AutoSize = True
            _COEffectsParalbl(I) = nlbl

            nnum.Left = _COEffectsParanum(I - 1).Location.X
            nnum.Top = _COEffectsParanum(I - 1).Location.Y + ParamHöhe
            nnum.Size = _COEffectsParanum(I - 1).Size
            nnum.Visible = _COEffectsParanum(I - 1).Visible
            nnum.Minimum = 0
            nnum.Maximum = 9999999
            _COEffectsParanum(I) = nnum

            ncmb.Left = _COEffectsParacmb(I - 1).Location.X
            ncmb.Top = _COEffectsParacmb(I - 1).Location.Y + ParamHöhe
            ncmb.Size = _COEffectsParacmb(I - 1).Size
            ncmb.Visible = _COEffectsParacmb(I - 1).Visible
            _COEffectsParacmb(I) = ncmb

            _COEffectsParalbl(I - 1).Parent.Controls.Add(nlbl)
            _COEffectsParanum(I - 1).Parent.Controls.Add(nnum)
            _COEffectsParacmb(I - 1).Parent.Controls.Add(ncmb)
        Next

    End Sub




    'Auto-generated subs
    Public Sub New()

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        Me.Size = My.Settings.Größe
        FontFett = btnLandkarteOrdner.Font

        Sprache = My.Settings.Sprache
        If Sprache = Sprachen.Deutsch Then
            mnuSpracheDeutsch.Checked = True
            mnuSpracheEnglisch.Checked = False
        Else
            mnuSpracheDeutsch.Checked = False
            mnuSpracheEnglisch.Checked = True
        End If
        If My.Settings.Resourcenpfad = "" Then
            Dim About As New frmAbout
            About.ShowDialog()
            If MsgBox("Do you want to select the Resources folder of Commander Wars?", MsgBoxStyle.YesNo, "Folder browsing") = MsgBoxResult.Yes Then ResourcesFestlegen()
        End If
        Sprachupdate()


        cmbCuFähigkeit.Items.Clear()
        cmbCuFähigkeit.Items.AddRange(SpezialFähigkÜbersetzt)
        cmbCuFähigkeit.Text = SpezialFähigkÜbersetzt(0)

        cmbCuBewgungsart.Items.Clear()
        cmbCuBewgungsart.Items.AddRange(BewegungsartÜbersetzt)
        cmbCuBewgungsart.Text = BewegungsartÜbersetzt(0)

        cmbCuWaffe1.Items.Clear()
        cmbCuWaffe1.Items.AddRange(WaffenÜbersetzt)
        cmbCuWaffe1.Text = WaffenÜbersetzt(0)

        cmbCuWaffe2.Items.Clear()
        cmbCuWaffe2.Items.AddRange(WaffenÜbersetzt)
        cmbCuWaffe2.Text = WaffenÜbersetzt(0)

        cmbCuExplosion.Text = "land"
        'Entladungsuntergrund Tabelle
        dgvCuLadungsUntergrund.Rows.Clear()
        For I = 0 To LandschaftÜbersetzt.Length - 1
            Dim Z As DataGridViewTextBoxCell = dgvCuLadungsUntergrund.Rows(dgvCuLadungsUntergrund.Rows.Add()).Cells(SpalteCuTerrainUntergrund.Index)
            Z.Value = LandschaftÜbersetzt(I)
            Z.Style.BackColor = Color.Red
            Z.Style.SelectionForeColor = Color.Black
            Z.Style.SelectionBackColor = Color.Red
        Next
        'Geladene Einheiten Tabelle
        dgvCuGeladeneEinheiten.Rows.Clear()
        For I = 0 To UnitÜbersetzt.Length - 1
            Dim Z As DataGridViewTextBoxCell = dgvCuGeladeneEinheiten.Rows(dgvCuGeladeneEinheiten.Rows.Add()).Cells(SpalteCuGeladeneEinheiten.Index)
            Z.Value = UnitÜbersetzt(I)
            Z.Style.BackColor = Color.Red
            Z.Style.SelectionForeColor = Color.Black
            Z.Style.SelectionBackColor = Color.Red
            Z.ReadOnly = True
        Next
        'Deffence Tabelle
        dgvCuDefence.Rows.Clear()
        For I = 1 To WaffenÜbersetzt.Length - 1
            Dim Z As DataGridViewTextBoxCell = dgvCuDefence.Rows(dgvCuDefence.Rows.Add()).Cells(SpalteCuDefenceUnit.Index)
            Z.Value = WaffenÜbersetzt(I)
            Z.ReadOnly = True
            Z = dgvCuDefence.Rows(Z.RowIndex).Cells(SpalteCuDefenceWert.Index)
            Z.Value = "-1"
        Next
        'Waffentabelle
        dgvCuWaffe.Rows.Clear()
        For I = 1 To UnitÜbersetzt.Length - 1
            Dim Z As DataGridViewTextBoxCell = dgvCuWaffe.Rows(dgvCuWaffe.Rows.Add()).Cells(SpalteCuWaffeOpfer.Index)
            Z.Value = UnitÜbersetzt(I)
            Z.ReadOnly = True
            Z = dgvCuWaffe.Rows(Z.RowIndex).Cells(SpalteCuDamage.Index)
            Z.Value = "-1"
        Next


        'Bewegungstabelle
        dgvCuBewegungstabelle.Rows.Clear()
        For I = 1 To LandschaftÜbersetzt.Length - 1
            Dim Z As DataGridViewTextBoxCell = dgvCuBewegungstabelle.Rows(dgvCuBewegungstabelle.Rows.Add()).Cells(SpalteCuName.Index)
            Z.Value = LandschaftÜbersetzt(I)
            Z.ReadOnly = True
            Z = dgvCuBewegungstabelle.Rows(Z.RowIndex).Cells(SpalteCuSonne.Index)
            Z.Value = "-1"
            Z = dgvCuBewegungstabelle.Rows(Z.RowIndex).Cells(SpalteCuRegen.Index)
            Z.Value = "-1"
            Z = dgvCuBewegungstabelle.Rows(Z.RowIndex).Cells(SpalteCuSandsturm.Index)
            Z.Value = "-1"
            Z = dgvCuBewegungstabelle.Rows(Z.RowIndex).Cells(SpalteCuSnow.Index)
            Z.Value = "-1"
        Next

        dgvCuProd.Rows.Clear()
        Dim Zelle As DataGridViewTextBoxCell = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Hafen")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Basis")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Flughafen")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Hauptquartier")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Labor")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Stadt")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Turm")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Mine")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Radar")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red
        Zelle = dgvCuProd.Rows(dgvCuProd.Rows.Add()).Cells(SpalteCuBauenErlauben.Index)
        Zelle.Value = Sprachconverter.Translate("Pipestation")
        Zelle.Style.BackColor = Color.Red
        Zelle.Style.SelectionForeColor = Color.Black
        Zelle.Style.SelectionBackColor = Color.Red

        For i = 0 To FarbtabellenÜbersetzt.Length - 1
            If ArmeeID.Contains(FarbtabellenÜbersetzt(i)) Then FarbtabellenÜbersetzt(i) = getArmeString(FarbtabellenÜbersetzt(i))
        Next


        Dim Spalte As DataGridViewComboBoxColumn = dgvLandkarteBlockierteEinheiten.Columns.Item(0)
        Spalte.Items.Clear()
        For i = 0 To ArmeeÜbersetzt.Length - 1
            Spalte.Items.Add(ArmeeÜbersetzt(i))
        Next
        Spalte = dgvLandkarteBlockierteEinheiten.Columns.Item(1)
        Spalte.Items.Clear()
        For i = 0 To UnitÜbersetzt.Length - 1
            Spalte.Items.Add(UnitÜbersetzt(i))
        Next
        Spalte = SpalteIniDialogKO
        Spalte.Items.Clear()
        For i = 1 To KOÜbersetzt.Length - 1 'fangen wir mit eins an weil hier hat das - nichts zu suchen. Es muss immer einer schwätzten und wenns ein Offizier ist!
            Spalte.Items.Add(KOÜbersetzt(i))
        Next
        Spalte = SpalteScriptDialogKO
        Spalte.Items.Clear()
        For i = 1 To KOÜbersetzt.Length - 1 'fangen wir mit eins an weil hier hat das - nichts zu suchen. Es muss immer einer schwätzten und wenns ein Offizier ist!
            Spalte.Items.Add(KOÜbersetzt(i))
        Next
        Spalte = SpalteIniDialogFarbe
        Spalte.Items.Clear()
        Spalte.Items.Add("Orange Star")
        Spalte.Items.Add("Blue Moon")
        Spalte.Items.Add("Green Earth")
        Spalte.Items.Add("Yellow Comet")
        Spalte.Items.Add("Black Hole")
        Spalte.Items.Add("Metall Army")
        Spalte.Items.Add("Amber Coranne")
        Spalte.Items.Add("Brown Desert")
        Spalte.Items.Add("Jade Sun")
        Spalte.Items.Add("Pinc Cosmos")
        Spalte.Items.Add("Teal Galaxy")
        Spalte.Items.Add("Dark Matter")
        'Spalte = SpalteScriptDialogFarbe
        'Spalte.Items.Clear()
        'Spalte.Items.Add("Orange Star")
        'Spalte.Items.Add("Blue Moon")
        'Spalte.Items.Add("Green Earth")
        'Spalte.Items.Add("Yellow Comet")
        'Spalte.Items.Add("Black Hole")
        'Spalte.Items.Add("Metall Army")
        'Spalte.Items.Add("Amber Coranne")
        'Spalte.Items.Add("Brown Desert")
        'Spalte.Items.Add("Jade Sun")
        'Spalte.Items.Add("Pinc Cosmos")
        'Spalte.Items.Add("Teal Galaxy")
        'Spalte.Items.Add("Dark Matter")


        'For i = 0 To FarbtabellenÜbersetzt.Length - 1
        '    '  Dim Farbe As String = FarbtabellenÜbersetzt(i)

        '    Spalte.Items.Add(FarbtabellenÜbersetzt(i))
        'Next

        Spalte = dgvLandkarteMissionen.Columns.Item(4)
        Spalte.Items.Clear()
        Spalte.Items.Add("not choosable")
        Spalte.Items.Add("choosable")

        Dim Sp As DataGridViewColumn
        For Each Sp In dgvIniDialog.Columns
            Sp.SortMode = DataGridViewColumnSortMode.NotSortable
        Next
        For Each Sp In dgvLandkarteBlockierteEinheiten.Columns
            Sp.SortMode = DataGridViewColumnSortMode.NotSortable
        Next
        For Each Sp In dgvLandkarteMissionen.Columns
            Sp.SortMode = DataGridViewColumnSortMode.NotSortable
        Next



        'OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad
        OpenFileDialog1.FileName = My.Settings.Resourcenpfad
        mnuShowInvalidScriptLines.Checked = My.Settings.ShowInvalidCode

        _condParalbl(0) = lblScriptCondParamInfo1
        _condParanum(0) = numScriptCondParamInfo1
        _condParanum(0).Minimum = 0
        _condParanum(0).Maximum = 9999999
        _condParacmb(0) = cmbScriptCondParamInfo1
        For i = 1 To 6
            Dim nlbl As New Label
            Dim nnum As New NumericUpDown
            Dim ncmb As New ComboBox
            nlbl.Text = "*" + (i + 1).ToString + "*:"
            nlbl.Left = _condParalbl(i - 1).Location.X
            nlbl.Top = _condParalbl(i - 1).Location.Y + ParamHöhe
            nlbl.Visible = _condParalbl(i - 1).Visible
            nlbl.AutoSize = True
            _condParalbl(i) = nlbl

            nnum.Left = _condParanum(i - 1).Location.X
            nnum.Top = _condParanum(i - 1).Location.Y + ParamHöhe
            nnum.Size = _condParanum(i - 1).Size
            nnum.Visible = _condParanum(i - 1).Visible
            nnum.Minimum = 0
            nnum.Maximum = 9999999
            _condParanum(i) = nnum

            ncmb.Left = _condParacmb(i - 1).Location.X
            ncmb.Top = _condParacmb(i - 1).Location.Y + ParamHöhe
            ncmb.Size = _condParacmb(i - 1).Size
            ncmb.Visible = _condParacmb(i - 1).Visible
            _condParacmb(i) = ncmb

            _condParalbl(i - 1).Parent.Controls.Add(nlbl)
            _condParanum(i - 1).Parent.Controls.Add(nnum)
            _condParacmb(i - 1).Parent.Controls.Add(ncmb)
        Next
        For i = 0 To 6
            Dim nlbl As New Label
            Dim nnum As New NumericUpDown
            Dim ncmb As New ComboBox
            nlbl.Text = "*" + (i + 1).ToString + "*:"
            nlbl.Left = _condParalbl(i).Location.X
            nlbl.Top = _condParalbl(i).Location.Y
            nlbl.Visible = _condParalbl(i).Visible
            nlbl.AutoSize = True
            _EventParalbl(i) = nlbl

            nnum.Left = _condParanum(i).Location.X
            nnum.Top = _condParanum(i).Location.Y
            nnum.Size = _condParanum(i).Size
            nnum.Visible = _condParanum(i).Visible
            nnum.Minimum = 0
            nnum.Maximum = 9999999
            _EventParanum(i) = nnum

            ncmb.Left = _condParacmb(i).Location.X
            ncmb.Top = _condParacmb(i).Location.Y
            ncmb.Size = _condParacmb(i).Size
            ncmb.Visible = _condParacmb(i).Visible
            _EventParacmb(i) = ncmb

            lblScriptEventTipp.Parent.Controls.Add(nlbl)
            lblScriptEventTipp.Parent.Controls.Add(nnum)
            lblScriptEventTipp.Parent.Controls.Add(ncmb)
        Next
        'Start Wetter
        cbStartwetter.Items.Clear()
        Dim W() As String = [Enum].GetNames(ObjektSpielfeld.Wetterarten.Regen.GetType)
        For I = 0 To W.Length - 1
            cbStartwetter.Items.Add(Sprachconverter.Translate(W(I)))
        Next
        cbStartwetter.SelectedIndex = 0
        'Game Modis hinzufügen
        cmbLandkarteGameMode.Items.Clear()
        cmbLandkarteGameMode.Items.Add("None")
        cmbLandkarteGameMode.Items.AddRange([Enum].GetNames(CommanderWarsGameModi.AdvanceWars.GetType))

        cmbIniGameModus.Items.Clear()
        cmbIniGameModus.Items.Add("None")
        cmbIniGameModus.Items.AddRange([Enum].GetNames(CommanderWarsGameModi.AdvanceWars.GetType))
        cmbIniGameModus.SelectedIndex = 0

        Dim X As Integer = 5
        Dim Y As Integer = 5

        'Spezial Spieler Auswahl erstellen
        Array.Resize(KOCheckboxen, KOID.Length - 1)
        For I = 0 To KOID.Length - 2
            Dim CB As New CheckBox()

            CB.Location = New Point(X, Y)
            CB.Text = getKOString(KOID(I))
            CB.Name = KOID(I)
            CB.Checked = False
            CB.AutoSize = False
            CB.Width = 90
            pKOAuswahl.Controls.Add(CB)
            KOCheckboxen(I) = CB

            If X >= 505 Then
                Y += 25
                X = 5
            Else
                X += 100
            End If


        Next
        Dim Prios As String() = [Enum].GetNames(KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal.GetType)
        cbAutoBauLuft.Items.Clear()
        cbAutoBauLuft.Items.AddRange(Prios)
        cbAutoBauLuft.SelectedIndex = KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal
        cbAutoBauLand.Items.Clear()
        cbAutoBauLand.Items.AddRange(Prios)
        cbAutoBauLand.SelectedIndex = KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal
        cbAutoBauSee.Items.Clear()
        cbAutoBauSee.Items.AddRange(Prios)
        cbAutoBauSee.SelectedIndex = KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal
        cbAutoBauDirekt.Items.Clear()
        cbAutoBauDirekt.Items.AddRange(Prios)
        cbAutoBauDirekt.SelectedIndex = KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal
        cbAutoBauIndirekt.Items.Clear()
        cbAutoBauIndirekt.Items.AddRange(Prios)
        cbAutoBauIndirekt.SelectedIndex = KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal
        cbAutoBauInfantrie.Items.Clear()
        cbAutoBauInfantrie.Items.AddRange(Prios)
        cbAutoBauInfantrie.SelectedIndex = KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal
        cbAutoBauTransport.Items.Clear()
        cbAutoBauTransport.Items.AddRange(Prios)
        cbAutoBauTransport.SelectedIndex = KIGenerellerSuperBau.PrioritätsBau.Prioritäten.Normal
        'Custom KO
        IniCustomCOEffect()
        cbCustomCOArmy.Items.Clear()
        cbCustomCOArmy.Items.AddRange(ArmeeÜbersetzt)
        cbCustomCOArmy.SelectedIndex = 0
        cbWeatherBonus.Items.Clear()
        cbWeatherBonus.Items.AddRange([Enum].GetNames(ObjektSpielfeld.Wetterarten.Regen.GetType))
        cbWeatherBonus.SelectedIndex = 0
        cbStärkeBonus.Items.Clear()
        cbStärkeBonus.Items.AddRange([Enum].GetNames(ObjektKO.Kampfboni.EnemyAttack.GetType))
        cbStärkeBonus.SelectedIndex = 0
        cbBuildBuildings.Items.Clear()
        cbBuildBuildings.Items.AddRange([Enum].GetNames(ObjektKO.ReperaturGebäude.Own.GetType))
        cbBuildBuildings.SelectedIndex = 0
        cbRepairBuildings.Items.Clear()
        cbRepairBuildings.Items.AddRange([Enum].GetNames(ObjektKO.ReperaturGebäude.Own.GetType))
        cbRepairBuildings.SelectedIndex = 0
        'Offence Table
        cbOffenceTable.Items.Clear()
        cbOffenceTable.Items.Add("All")
        cbOffenceTable.Items.Add("Sea and Air")
        cbOffenceTable.Items.Add("Direct")
        cbOffenceTable.Items.Add("Indirect")
        cbOffenceTable.Items.Add("Copter")
        cbOffenceTable.Items.Add("Infantry")
        cbOffenceTable.SelectedIndex = 0
        cbDeffenceTable.Items.Clear()
        cbDeffenceTable.Items.Add("All")
        cbDeffenceTable.Items.Add("Sea and Air")
        cbDeffenceTable.Items.Add("Direct")
        cbDeffenceTable.Items.Add("Indirect")
        cbDeffenceTable.Items.Add("Copter")
        cbDeffenceTable.Items.Add("Infantry")
        cbDeffenceTable.SelectedIndex = 0
        'Moving Boost
        cbMovingBoostTable.Items.Clear()
        cbMovingBoostTable.Items.Add("All")
        cbMovingBoostTable.Items.Add("Indirects and Directs")
        cbMovingBoostTable.Items.Add("Hovercrafts")
        cbMovingBoostTable.Items.Add("Infantry")
        cbMovingBoostTable.Items.Add("Sea")
        cbMovingBoostTable.Items.Add("Transport Units")
        cbMovingBoostTable.Items.Add("Tanks")
        cbMovingBoostTable.Items.Add("Directs")
        cbMovingBoostTable.SelectedIndex = 0
        'Last Change here.
        cbCustomCOPower.SelectedIndex = 0

        setDefaultLandkarte()

        Ini = True
    End Sub

    Private Sub mnuSpeichern_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSpeichern.Click
        Save()
    End Sub
    Private Sub mnuSpeichernUnter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSpeichernUnter.Click
        SpeichernUnter()
    End Sub

    Private Sub frmScriptWriter_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If frmSplashScreen.SplScreen IsNot Nothing Then
            frmSplashScreen.SplScreen.Close()
        End If
    End Sub

    Private Sub Form1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
        If Ini Then
            My.Settings.Größe = Me.Size
            My.Settings.Save()
        End If
    End Sub

    Private Sub tabControl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tabControl.SelectedIndexChanged
        If tabControl.SelectedTab.Text = "Script" Then
            If Not ScriptGeladen Then ' (My.Settings.Resourcenpfad + "Scripts\" + txtScriptName.Text + ".script").ToLower <> scDateiname.ToLower Then
                'Wir müssen ein anderes/ neues script laden.

                LoadScript()

            End If
        End If
    End Sub

    Private Sub numSpieler_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles numSpieler.ValueChanged

        'I hope that the input is valid
        If SpielerAnz > numSpieler.Value Then
            For i = numSpieler.Value To SpielerAnz - 1
                'Alle, die zuviel sind, müssen gelöscht werden.
                _btnFarbe(i).Dispose()
                _cbUnbesiegbar(i).Dispose()
                _cmbBauliste(i).Dispose()
                _cmbKI(i).Dispose()
                _cmbKO1(i).Dispose()
                _cmbKO2(i).Dispose()
                _lblTeam(i).Dispose()
                _numFondspF(i).Dispose()
                _numFondspS(i).Dispose()
                _numStartGeld(i).Dispose()
            Next
            'Die neue Spieler anzahl festlegen, und die überzähligen Spieler vollkommen rausschmeißen:
            SpielerAnz = numSpieler.Value
            Array.Resize(_cmbBauliste, SpielerAnz)
            Array.Resize(_btnFarbe, SpielerAnz)
            Array.Resize(_numFondspF, SpielerAnz)
            Array.Resize(_numFondspS, SpielerAnz)
            Array.Resize(_cmbKI, SpielerAnz)
            Array.Resize(_cmbKO1, SpielerAnz)
            Array.Resize(_cmbKO2, SpielerAnz)
            Array.Resize(_numStartGeld, SpielerAnz)
            Array.Resize(_lblTeam, SpielerAnz)
            Array.Resize(_cbUnbesiegbar, SpielerAnz)
            Array.Resize(ZusatzInfos, SpielerAnz)
        ElseIf SpielerAnz < numSpieler.Value Then
            'Es müssen neue Spieler erschaffen werden..
            Array.Resize(_cmbBauliste, numSpieler.Value)
            Array.Resize(_btnFarbe, numSpieler.Value)
            Array.Resize(_numFondspF, numSpieler.Value)
            Array.Resize(_numFondspS, numSpieler.Value)
            Array.Resize(_cmbKI, numSpieler.Value)
            Array.Resize(_cmbKO1, numSpieler.Value)
            Array.Resize(_cmbKO2, numSpieler.Value)
            Array.Resize(_numStartGeld, numSpieler.Value)
            Array.Resize(_lblTeam, numSpieler.Value)
            Array.Resize(_cbUnbesiegbar, numSpieler.Value)
            Array.Resize(ZusatzInfos, numSpieler.Value)

            For i = SpielerAnz To numSpieler.Value - 1
                addSpielerInSpielerinfos(i, getStandardTeam(i + 1), StandardKI, getStandardFarbe(i + 1), StandardFond, StandardFondPS, StandardFondPF, False, StandardBauliste, getKOString("ANDY"), getKOString("-"))
            Next

            SpielerAnz = numSpieler.Value
        End If



        'Player Informationen setzen!
        numSelectedPlayer.Maximum = numSpieler.Value
        If numSelectedPlayer.Minimum <= 0 Then
            numSelectedPlayer.Minimum = 1
        End If
        If Player.Count < numSpieler.Value Then
            For I = 1 To numSpieler.Value
                Player.Add(New PlayerInfos(getKOID(_cmbKO1(numSpieler.Value - 1).SelectedText), getKOID(_cmbKO2(numSpieler.Value - 1).SelectedText)))
            Next
        Else
            Player.RemoveRange(numSpieler.Value, Player.Count - numSpieler.Value)
        End If
        'For i = 0 To SpielerAnz - 1
        '    _cmbBauliste(i).SelectedIndex = 3
        '    _btnFarbe(i).Tag = "Orange.bmp"
        '    _numFondspF(i).Value = 30000
        '    _numFondspS(i).Value = 1000
        '    _cmbKI(i).SelectedIndex = 3
        '    _cmbKO1(i).SelectedItem = "Andy"
        '    _cmbKO2(i).sele = "-"
        '    _StartGeld(i) = 0
        '    _Team(i) = "A"
        '    _Unbesiegbar(i) = False
        'Next
    End Sub

    Private Sub txtScriptName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtScriptName.TextChanged
        CheckTextScriptFarbe()
    End Sub
    Private Sub txtNächsteKarte_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNächsteKarte.TextChanged
        If txtNächsteKarte.Text.Trim = "" Then
            txtNächsteKarte.BackColor = Color.White
        Else
            If Dateiname.Trim = "" Then
                txtNächsteKarte.BackColor = Color.White
                Exit Sub
            End If
            If My.Computer.FileSystem.FileExists(Dateiname.Remove(Dateiname.LastIndexOf("\") + 1) + txtNächsteKarte.Text + ".map") Then
                txtNächsteKarte.BackColor = Color.Lime
            Else
                txtNächsteKarte.BackColor = Color.Red
            End If
        End If
    End Sub

    Private Sub mnuResourcenpfad_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuResourcenpfad.Click
        ResourcesFestlegen()
    End Sub

    Private Sub mnuSpracheDeutsch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSpracheDeutsch.Click
        mnuSpracheEnglisch.Checked = False
        mnuSpracheDeutsch.Checked = True
        Sprache = Sprachen.Deutsch

        Sprachupdate()

        MsgBox("Am besten beendest du die Anwendung jetzt und startest sie dannach neu!", MsgBoxStyle.Information, "Neustart erforderlich")
    End Sub
    Private Sub mnuSpracheEnglisch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSpracheEnglisch.Click
        mnuSpracheEnglisch.Checked = True
        mnuSpracheDeutsch.Checked = False
        Sprache = Sprachen.English

        Sprachupdate()

        MsgBox("Please restart the application! Otherwise Errors will occur!", MsgBoxStyle.Information, "Restart necessary")
    End Sub

    Private Sub mnuOpenIni_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuOpenIni.Click
        LoadIni()
    End Sub

    Private Sub mnuHilfe_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuHilfe.Click
        MsgBox("Sorry, this feature isn't available in the demo version of Script writer." + Environment.NewLine + "please register or crack the program, to make it fully functionable", MsgBoxStyle.Information, "not registered yet")
    End Sub

    Private Sub lbScripts_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles lbScripts.KeyDown
        Select Case e.KeyCode
            Case Keys.Delete
                DeleteScriptInListBoxCurrent()
        End Select
    End Sub

    Private Sub lbScripts_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbScripts.SelectedIndexChanged
        If lbScripts.SelectedIndex >= 0 Then
            scInd = lbScripts.SelectedIndex
            ScriptIndChanged()
        End If
    End Sub
    Private Sub lbScriptCondition_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbScriptCondition.SelectedIndexChanged
        If lbScriptCondition.SelectedIndex >= 0 Then
            scConditionInd = lbScriptCondition.SelectedIndex
            ScriptConditionsIndChanged()
        End If
    End Sub
    Private Sub lbScriptEvent_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbScriptEvent.SelectedIndexChanged
        If lbScriptEvent.SelectedIndex >= 0 Then
            scEventInd = lbScriptEvent.SelectedIndex
            ScriptEventsIndChanged()
        End If
    End Sub
    Private Sub txtScriptBeschreibung_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtScriptBeschreibung.TextChanged
        If txtScriptBeschreibung.Text.Trim = "" Then Exit Sub

        If scInd >= 0 Then
            lbScripts.Items.RemoveAt(scInd)
            lbScripts.Items.Insert(scInd, txtScriptBeschreibung.Text)
            lbScripts.SelectedIndex = scInd
            scripte(scInd).Desc = txtScriptBeschreibung.Text
        Else
            MsgBox("You have to select a script first. Please click on an existing script in the list above, or press the button ""New""!", MsgBoxStyle.Exclamation, "no valid input")
            txtScriptBeschreibung.Text = ""
        End If
    End Sub

    Private Sub btnScriptNeu_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScriptNeu.Click
        NewScript(, True)
    End Sub

    Private Sub btnScriptLöschen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScriptLöschen.Click
        DeleteScriptInListBoxCurrent()
    End Sub

    Private Sub mnuShowInvalidScriptLines_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuShowInvalidScriptLines.CheckedChanged
        My.Settings.ShowInvalidCode = mnuShowInvalidScriptLines.Checked
        My.Settings.Save()
    End Sub
    Private Sub mnuShowInvalidScriptLines_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuShowInvalidScriptLines.Click
        mnuShowInvalidScriptLines.Checked = Not mnuShowInvalidScriptLines.Checked
    End Sub


    Private Sub cmbScriptConditionArt_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbScriptConditionArt.SelectedIndexChanged
        If scInd < 0 Then Exit Sub
        If scConditionInd < 0 Then Exit Sub
        If cmbScriptConditionArt.SelectedIndex < 1 Then Exit Sub

        If scripte(scInd).Bedingungen(scConditionInd).Bedingungsart = objScript.getBedingungsart(cmbScriptConditionArt.SelectedItem) Then
            'Wenn es die gleiche Bedingung ist, dann laden wir die Daten aus dem Array, ansonsten halt die Standardbedingungen.
            AktuelleBedingung = scripte(scInd).Bedingungen(scConditionInd).Clone
        Else
            AktuelleBedingung = New objBedingung(objScript.getBedingungsart(cmbScriptConditionArt.SelectedItem))
        End If


        showBedingungen()
    End Sub
    Private Sub cmbScriptEventArt_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbScriptEventArt.SelectedIndexChanged
        If scInd < 0 Then Exit Sub
        If scEventInd < 0 Then Exit Sub
        If cmbScriptEventArt.SelectedIndex < 1 Then Exit Sub

        If scripte(scInd).Ereignisse(scEventInd).Ereignisart = objScript.getEreignisart(cmbScriptEventArt.SelectedItem) Then
            AktuellesEreignis = scripte(scInd).Ereignisse(scEventInd).Clone
        Else
            AktuellesEreignis = New objEreignis(objScript.getEreignisart(cmbScriptEventArt.SelectedItem))
        End If


        showEreignisse()
    End Sub

    Private Sub btnScriptConditionAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScriptConditionAdd.Click
        addScriptBedingung(scInd, Bedingungsarten.TagGleich)
        ScriptBedingungAktualisieren()
    End Sub
    Private Sub btnScriptEventAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScriptEventAdd.Click
        addScriptEreignis(scInd, Ereignisarten.Gewonnen)
        ScriptEreignisAktualisieren()
    End Sub
    Private Sub btnScriptConditionRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScriptConditionRemove.Click
        deleteScriptBedingung(scInd, scConditionInd)
    End Sub
    Private Sub btnScriptEventRemove_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScriptEventRemove.Click
        deleteScriptEreignis(scInd, scEventInd)
    End Sub

    Private Sub btnScriptConditionSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScriptConditionSave.Click
        SaveConditions()
    End Sub
    Private Sub btnScriptEventSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScriptEventSave.Click
        SaveEvents()
    End Sub

    Private Sub mnuNeuIni_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuNeuIni.Click
        NeuIni()
    End Sub
    Private Sub mnuNeuScript_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuNeuScript.Click
        NeuScript()
    End Sub

    Private Sub mnuOpenScript_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuOpenScript.Click
        LoadScriptOpen()
    End Sub

    Private Sub mnuAbout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
        Dim About As New frmAbout
        About.ShowDialog()
    End Sub

    Private Sub mnuSaveIni_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSaveIni.Click
        SaveIni()
    End Sub
    Private Sub mnuSaveScript_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSaveScript.Click
        SaveScript()
    End Sub

    Private Sub mnuOpenWorldmap_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuOpenWorldmap.Click
        LoadIniLandkarteOpen()
    End Sub

    Private Sub txtLandkarteHintergrund_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtLandkarteHintergrund.MouseDown
        Select Case e.Button
            Case Windows.Forms.MouseButtons.Middle
                OpenFileDialog1.Title = "choose a background Image"
                OpenFileDialog1.Filter = "Picture|*.bmp;*.png|All Files|*.*"
                OpenFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
                If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                    Dim HintName As String
                    HintName = LandkartenName + "_Background"
                    If LandkartenName.Trim = "" Then
                        HintName = txtLandkarteHintergrund.Text
                    End If
                    If (Not My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Landkarten\" + txtLandkarteHintergrund.Text + ".png")) And (Not txtLandkarteHintergrund.Text.Trim = "") Then
                        HintName = txtLandkarteHintergrund.Text
                    End If
                    If HintName = "" Then
                        MsgBox("Please choose a campaign directory first!", MsgBoxStyle.Critical, "No valid path")
                        Exit Sub
                    End If
                    My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName, My.Settings.Resourcenpfad + "Landkarten\" + HintName + ".png", True)
                    txtLandkarteHintergrund.Text = HintName
                End If
        End Select
    End Sub

    Private Sub txtLandkarteHintergrund_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLandkarteHintergrund.TextChanged
        If txtLandkarteHintergrund.Text.Trim = "" Then
            txtLandkarteHintergrund.BackColor = Color.White
        Else
            If My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Landkarten\" + txtLandkarteHintergrund.Text + ".png") Then
                txtLandkarteHintergrund.BackColor = Color.Lime
            Else
                txtLandkarteHintergrund.BackColor = Color.Red
            End If
        End If
    End Sub

    Private Sub mnuNeuWorldMap_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuNeuWorldMap.Click
        NeuLandkarte()
    End Sub

    Private Sub dgvLandkarteMissionen_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvLandkarteMissionen.CellValueChanged
        If e.RowIndex < 0 Then Exit Sub
        If e.ColumnIndex < 0 Then Exit Sub
        Select Case e.ColumnIndex
            Case SpalteLandkarteBild.Index
                Dim Kartennnname As String = CType(dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Value, String).Trim
                If Kartennnname = "" Then
                    dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.White
                    dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.White
                Else
                    If My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Landkarten\" + Kartennnname + ".png") Then
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Lime
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Lime
                    Else
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Red
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red
                    End If
                End If
            Case SpalteLandkarteKartenname.Index
                Dim Kartennnname As String = CType(dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Value, String).Trim
                If Kartennnname = "" Then
                    dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.White
                    dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.White
                Else
                    If My.Computer.FileSystem.FileExists(OrdnernameLandkarte + "\" + Kartennnname + ".map") Then
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Lime
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Lime
                    Else
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Red
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red
                    End If
                End If
        End Select
    End Sub


    Private Sub dgvLandkarteMissionen_RowsAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles dgvLandkarteMissionen.RowsAdded
        ' If Not Ini Then Exit Sub
        For ind = e.RowIndex To e.RowIndex + e.RowCount - 1
            dgvLandkarteMissionen.Rows(ind).Cells(0).Value = ind
            ' Dim cmb As DataGridViewComboBoxCell = dgvLandkarteMissionen.Rows(ind).Cells(4)
            ' cmb.Value = cmb.Items(0)

        Next
    End Sub

    Private Sub mnuSaveWorldmap_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSaveWorldmap.Click
        SaveLandkarte()
    End Sub
    Private Sub mnuSpeichernUnterLandkarte_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuSpeichernUnterLandkarte.Click
        SpeichernUnterLandkarte()
    End Sub

    'Damit man nicht ganz so viele Klicks braucht...
    Private Sub dgvIniDialog_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvIniDialog.CellClick, dgvLandkarteBlockierteEinheiten.CellClick, dgvLandkarteMissionen.CellClick, dgvScriptDialog.CellClick
        If e.ColumnIndex < 0 Then Exit Sub
        If e.RowIndex < 0 Then Exit Sub
        Dim dgv As DataGridView = CType(sender, DataGridView)
        If Not dgv(e.ColumnIndex, e.RowIndex).IsInEditMode Then
            'If dgv(e.ColumnIndex, e.RowIndex).EditType IsNot Nothing Then
            Select Case dgv(e.ColumnIndex, e.RowIndex).GetType.ToString().ToLower
                Case "System.Windows.Forms.DataGridViewComboBoxCell".ToLower
                    SendKeys.Send("{F4}")
                Case "System.Windows.Forms.DataGridViewTextBoxCell".ToLower
                    SendKeys.Send("{F2}")
            End Select
            'End If
        End If
    End Sub

    Private Sub mnuNeuKarte_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuNeuKarte.Click
        OpenFileDialog1.Title = "Open map"
        OpenFileDialog1.DefaultExt = ".map"
        OpenFileDialog1.Filter = "maps|*.map|All Files|*.*"
        If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "Karten\") Then OpenFileDialog1.InitialDirectory = My.Settings.Resourcenpfad + "Karten\"

        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            'mal grundsätzlich neu machen...
            NeuIni()
            NeuLandkarte()
            NeuScript()
            numSpieler.Value = Hauptmenü.KarteDefaultLaden(OpenFileDialog1.FileName).Spieler.Length - 1

            Dateiname = OpenFileDialog1.FileName.Replace(".map", ".ini")
            txtKartenname.Text = OpenFileDialog1.FileName.Remove(0, OpenFileDialog1.FileName.LastIndexOf("\") + 1).Replace(".map", "")
        End If
    End Sub

    Private Sub dgvIniDialog_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvIniDialog.CellMouseDown
        ' F I L T E R :

        '        ? - Entspricht genau einem Zeichen
        '        * - Entspricht null oder mehr Zeichen
        '        ! - Gibt einen Ausschlussnamensfilter an
        '        \ - Gibt einen Ordnernamensfilter an
        '        ; - Namensfiltertrennzeichen

        'Hinweis:
        'Die folgenden Zeichen sind in Namensfiltern nicht zulässig: “ < > | \b \0 \t und die Zeichen 0-31.

        '        Bsp:
        '        *.cs;!objd\;!obj\;!bin\                Entspricht allen C#-Dateien, die sich nicht in den Ordnern objd, obj oder bin befinden.



        Select Case e.Button
            Case Windows.Forms.MouseButtons.Left
                If SpalteIniDialogMusik.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "!Custom\Music\") Then Me.ofdMusik.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\Music\"
                    Me.ofdMusik.Filter = "Music|*.mp3;*.wav|Everything|*.*"
                    If Me.ofdMusik.ShowDialog() = Windows.Forms.DialogResult.OK Then
                        dgvIniDialog(e.ColumnIndex, e.RowIndex).Value = Me.ofdMusik.FileName.Replace(My.Settings.Resourcenpfad + "!Custom\Music\", "")
                    End If
                ElseIf SpalteIniDialogBild.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "!Custom\Pictures") Then Me.ofdMusik.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\Pictures"
                    Me.ofdMusik.Filter = "Pictures|*.png;*.bmp|Videos|*.avi|Everything|*.*"
                    If Me.ofdMusik.ShowDialog() = Windows.Forms.DialogResult.OK Then
                        dgvIniDialog(e.ColumnIndex, e.RowIndex).Value = Me.ofdMusik.FileName.Replace(My.Settings.Resourcenpfad + "!Custom\Pictures\", "")
                    End If
                End If
            Case Windows.Forms.MouseButtons.Middle
                If SpalteIniDialogMusik.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvIniDialog(e.ColumnIndex, e.RowIndex).Value = ""
                ElseIf SpalteIniDialogBild.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvIniDialog(e.ColumnIndex, e.RowIndex).Value = ""
                End If
            Case Windows.Forms.MouseButtons.Right
                If SpalteIniDialogMusik.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvIniDialog(e.ColumnIndex, e.RowIndex).Value = "default"
                ElseIf SpalteIniDialogBild.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvIniDialog(e.ColumnIndex, e.RowIndex).Value = "default"
                End If
        End Select

    End Sub

    Private Sub cbSiegEinnehmen_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbSiegEinnehmen.CheckedChanged
        numSiegEinnehmen.Enabled = cbSiegEinnehmen.Checked
    End Sub
    Private Sub cbSiegZeit_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbSiegZeit.CheckedChanged
        numSiegZeit.Enabled = cbSiegZeit.Checked
    End Sub

    Private Sub dgvIniDialog_RowsAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles dgvIniDialog.RowsAdded
        For i = e.RowIndex To e.RowIndex + e.RowCount - 1
            dgvIniDialog(SpalteIniDialogGesichtsausdruck.Index, i).Value = "Normal"
            dgvIniDialog(SpalteIniDialogKO.Index, i).Value = "Andy"
            dgvIniDialog(SpalteIniDialogFarbe.Index, i).Value = "Orange Star"
        Next
    End Sub

    Private Sub dgvScriptDialog_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvScriptDialog.CellMouseDown
        ' F I L T E R :

        '        ? - Entspricht genau einem Zeichen
        '        * - Entspricht null oder mehr Zeichen
        '        ! - Gibt einen Ausschlussnamensfilter an
        '        \ - Gibt einen Ordnernamensfilter an
        '        ; - Namensfiltertrennzeichen

        'Hinweis:
        'Die folgenden Zeichen sind in Namensfiltern nicht zulässig: “ < > | \b \0 \t und die Zeichen 0-31.

        '        Bsp:
        '        *.cs;!objd\;!obj\;!bin\                Entspricht allen C#-Dateien, die sich nicht in den Ordnern objd, obj oder bin befinden.



        Select Case e.Button
            Case Windows.Forms.MouseButtons.Left
                If SpalteScriptDialogMusik.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "!Custom\Music\") Then Me.ofdMusik.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\Music\"
                    Me.ofdMusik.Filter = "Music|*.mp3;*.wav|Everything|*.*"
                    If Me.ofdMusik.ShowDialog() = Windows.Forms.DialogResult.OK Then
                        dgvScriptDialog(e.ColumnIndex, e.RowIndex).Value = Me.ofdMusik.FileName.Replace(My.Settings.Resourcenpfad + "!Custom\Music\", "")
                    End If
                ElseIf SpalteScriptDialogBild.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    If My.Computer.FileSystem.DirectoryExists(My.Settings.Resourcenpfad + "!Custom\Pictures") Then Me.ofdMusik.InitialDirectory = My.Settings.Resourcenpfad + "!Custom\Pictures"
                    Me.ofdMusik.Filter = "Pictures|*.png;*.bmp|Videos|*.avi|Everything|*.*"
                    If Me.ofdMusik.ShowDialog() = Windows.Forms.DialogResult.OK Then
                        dgvScriptDialog(e.ColumnIndex, e.RowIndex).Value = Me.ofdMusik.FileName.Replace(My.Settings.Resourcenpfad + "!Custom\Pictures\", "")
                    End If
                End If
            Case Windows.Forms.MouseButtons.Middle
                If SpalteScriptDialogMusik.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvScriptDialog(e.ColumnIndex, e.RowIndex).Value = ""
                ElseIf SpalteScriptDialogBild.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvScriptDialog(e.ColumnIndex, e.RowIndex).Value = ""
                End If
            Case Windows.Forms.MouseButtons.Right
                If SpalteScriptDialogMusik.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvScriptDialog(e.ColumnIndex, e.RowIndex).Value = "default"
                ElseIf SpalteScriptDialogBild.HeaderCell.ColumnIndex = e.ColumnIndex Then
                    dgvScriptDialog(e.ColumnIndex, e.RowIndex).Value = "default"
                End If
        End Select
    End Sub

    Private Sub dgvScriptDialog_RowsAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles dgvScriptDialog.RowsAdded
        For i = e.RowIndex To e.RowIndex + e.RowCount - 1
            dgvScriptDialog(SpalteScriptDialogGesichtsausdruck.Index, i).Value = "Normal"
            dgvScriptDialog(SpalteScriptDialogKO.Index, i).Value = "Andy"
            dgvScriptDialog(SpalteScriptDialogFarbe.Index, i).Value = "1"
        Next
    End Sub

    Private Sub dgvCuProd_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvCuProd.CellClick
        If e.RowIndex >= 0 Then
            Select Case e.ColumnIndex
                Case SpalteCuBauenErlauben.Index
                    If dgvCuProd(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red Then
                        dgvCuProd(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Lime
                        dgvCuProd(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Lime
                    Else
                        dgvCuProd(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red
                        dgvCuProd(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Red
                    End If
            End Select
        End If
    End Sub

    Private Sub dgvCuLadung_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvCuLadungsUntergrund.CellClick
        If e.RowIndex >= 0 Then
            Select Case e.ColumnIndex
                Case SpalteCuTerrainUntergrund.Index
                    If dgvCuLadungsUntergrund(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red Then
                        dgvCuLadungsUntergrund(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Lime
                        dgvCuLadungsUntergrund(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Lime
                    Else
                        dgvCuLadungsUntergrund(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red
                        dgvCuLadungsUntergrund(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Red
                    End If
            End Select
        End If
    End Sub

    Private Sub dgvCuGeladeneEinheiten_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvCuGeladeneEinheiten.CellClick
        If e.RowIndex >= 0 Then
            Select Case e.ColumnIndex
                Case SpalteCuGeladeneEinheiten.Index
                    dgvCuGeladeneEinheiten(e.ColumnIndex, e.RowIndex).Style.SelectionForeColor = Color.Black
                    If dgvCuGeladeneEinheiten(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red Then
                        dgvCuGeladeneEinheiten(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Lime
                        dgvCuGeladeneEinheiten(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Lime
                    Else
                        dgvCuGeladeneEinheiten(e.ColumnIndex, e.RowIndex).Style.BackColor = Color.Red
                        dgvCuGeladeneEinheiten(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Red
                    End If
            End Select
        End If
    End Sub

    Private Sub dgvCuDefence_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvCuDefence.CellEndEdit
        If e.RowIndex >= 0 Then
            Dim S As String = dgvCuDefence.Rows(e.RowIndex).Cells(SpalteCuDefenceWert.Index).Value
            If Not IsNumeric(S) Then
                dgvCuDefence.Rows(e.RowIndex).Cells(SpalteCuDefenceWert.Index).Value = "-1"
            End If
        End If
    End Sub

    Private Sub dgvCuBewegungstabelle_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvCuBewegungstabelle.CellEndEdit
        If e.RowIndex >= 0 Then
            Dim S As String = dgvCuBewegungstabelle.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
            If Not IsNumeric(S) Then
                dgvCuBewegungstabelle.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "-1"
            End If
        End If
    End Sub

    Private Sub mnuSaveCustomUnit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSaveCustomUnit.Click
        SaveCustomEinheit(My.Settings.Resourcenpfad + "!Custom\Unit\" + txtCuID.Text + ".ent")
    End Sub

    Private Sub mnuSaveCustomMovement_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSaveCustomMovement.Click
        SaveCustomBewegungsart(My.Settings.Resourcenpfad + "!Custom\Movement\" + tbCuBewegungsartname.Text + ".bew")
    End Sub

    Private Sub mnuSaveCustomWeapon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSaveCustomWeapon.Click
        SaveCustomWeapon(My.Settings.Resourcenpfad + "!Custom\Weapon\" + txtCuWaffenname.Text + ".waf")
    End Sub

    Private Sub mnuOpenCustomUnit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpenCustomUnit.Click
        LoadCustomUnit()
    End Sub

    Private Sub dgvCuWaffe_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvCuWaffe.CellEndEdit
        If e.RowIndex >= 0 Then
            Dim S As String = dgvCuWaffe.Rows(e.RowIndex).Cells(SpalteCuDamage.Index).Value
            If Not IsNumeric(S) Then
                dgvCuWaffe.Rows(e.RowIndex).Cells(SpalteCuDamage.Index).Value = "-1"
            End If
        End If
    End Sub

    Private Sub mnuCustomMovement_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCustomMovement.Click
        LoadCustomBewegungsart()
    End Sub

    Private Sub mnuOpenCustomWeapon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpenCustomWeapon.Click
        LoadCustomWeapon()
    End Sub

    Private Sub txtCuName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCuName.TextChanged
        If txtCuName.Text.Trim = "" Then
            btnCuBild.BackColor = Color.Transparent
            btnCuBildBew.BackColor = Color.Transparent
        Else
            If My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Einheiten\Bilder\CW\" + txtCuName.Text.Trim + ".png") Or My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Einheiten\Bilder\CW\" + txtCuName.Text.Trim + "+OS.png") Then
                btnCuBild.BackColor = Color.Lime
            Else
                btnCuBild.BackColor = Color.Red
            End If
            If My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Einheiten\Bilder\CW\" + txtCuName.Text.Trim + "+Laufen.png") Or My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Einheiten\Bilder\CW\" + txtCuName.Text.Trim + "+OS+Laufen.png") Then
                btnCuBildBew.BackColor = Color.Lime
            Else
                btnCuBildBew.BackColor = Color.Red
            End If
        End If
    End Sub

    Private Sub btnCuBild_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCuBild.Click
        If txtCuID.Text.Trim = "" Then
            MsgBox("Please enter a valid name for this unit!", MsgBoxStyle.Critical, "Error")
            Exit Sub
        End If
        ofdMusik.Filter = "Pictures|*.bmp;*.png|All Files|*.*"
        ofdMusik.Title = "Select Sprite"
        ofdMusik.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
        If ofdMusik.ShowDialog = Windows.Forms.DialogResult.OK Then
            'OK, dann also das Bild kopieren!
            My.Computer.FileSystem.CopyFile(ofdMusik.FileName, My.Settings.Resourcenpfad + "!Custom\Unit\Sprites\" + txtCuID.Text + ".png")
            'Existiert eine Maske?
            Dim S() As String = ofdMusik.FileName.Split(".")
            Dim Maskenname As String = ""
            For I = 0 To S.Length - 1
                If I = S.Length - 1 Then
                    Maskenname += "+Makse." + S(I)
                ElseIf I > 0 Then
                    Maskenname += "." + S(I)
                Else
                    Maskenname += S(I)
                End If
            Next
            If My.Computer.FileSystem.FileExists(Maskenname) Then
                My.Computer.FileSystem.CopyFile(Maskenname, My.Settings.Resourcenpfad + "!Custom\Unit\Sprites\" + txtCuID.Text + "+Maske.png")
            Else
                Hauptmenü.CreateMask(ofdMusik.FileName)
            End If
            btnCuBild.BackColor = Color.Lime
        End If
    End Sub
    Private Sub btnCuBildBew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCuBildBew.Click
        If txtCuID.Text.Trim = "" Then
            MsgBox("Please enter a valid name for this unit!", MsgBoxStyle.Critical, "Error")
            Exit Sub
        End If
        ofdMusik.Filter = "Pictures|*.bmp;*.png|All Files|*.*"
        ofdMusik.Title = "Select Sprite"
        ofdMusik.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
        If ofdMusik.ShowDialog = Windows.Forms.DialogResult.OK Then
            'OK, dann also das Bild kopieren!
            My.Computer.FileSystem.CopyFile(ofdMusik.FileName, My.Settings.Resourcenpfad + "!Custom\Unit\Sprites\" + txtCuID.Text + "+Laufen.png")
            'Existiert eine Maske?
            Dim S() As String = ofdMusik.FileName.Split(".")
            Dim Maskenname As String = ""
            For I = 0 To S.Length - 1
                If I = S.Length - 1 Then
                    Maskenname += "+Makse." + S(I)
                ElseIf I > 0 Then
                    Maskenname += "." + S(I)
                Else
                    Maskenname += S(I)
                End If
            Next
            If My.Computer.FileSystem.FileExists(Maskenname) Then
                My.Computer.FileSystem.CopyFile(Maskenname, My.Settings.Resourcenpfad + "!Custom\Unit\Sprites\" + txtCuID.Text + "+Laufen+Maske.png")
            Else
                Hauptmenü.CreateMask(ofdMusik.FileName)
            End If
            btnCuBildBew.BackColor = Color.Lime
        End If
    End Sub
    Structure ZusatzInfo
        Dim KO1() As String
        Dim KO2() As String

    End Structure

    Private Sub txtCuID_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCuID.TextChanged
        CheckTextCuIDFarbe()
    End Sub

    Private Sub btnLandkarteOrdner_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLandkarteOrdner.Click
        fbdAllgemein.Description = "select your campaign folder"
        fbdAllgemein.SelectedPath = My.Settings.Resourcenpfad + "Karten\"
        If fbdAllgemein.ShowDialog = Windows.Forms.DialogResult.OK Then
            If fbdAllgemein.SelectedPath.StartsWith(My.Settings.Resourcenpfad + "Karten\") Then
                OrdnernameLandkarte = fbdAllgemein.SelectedPath
                If Not OrdnernameLandkarte.EndsWith(".kamp") Then
                    'Kampagnen müssen mit .kamp enden!
                    Try
                        My.Computer.FileSystem.RenameDirectory(OrdnernameLandkarte, OrdnernameLandkarte.Remove(0, OrdnernameLandkarte.LastIndexOf("\") + 1) + ".kamp")
                        OrdnernameLandkarte += ".kamp"
                        MsgBox("Campaign folders have to end with "".kamp"", that's why I just renamed the Directory", MsgBoxStyle.Information, "mistake corrected")
                    Catch ex As Exception
                        MsgBox("You have to make sure, that your Campaign-Directory ends with "".kamp""!", MsgBoxStyle.Exclamation, "false ending")
                    End Try
                End If
                DateinameLandkarte = OrdnernameLandkarte + "\Landkarte.ini"
            End If
        End If
        CheckLandkarteOrdnerFarbe()
    End Sub


    Private Sub dgvLandkarteMissionen_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvLandkarteMissionen.CellMouseDown
        If e.RowIndex < 0 Then Exit Sub
        If e.ColumnIndex < 0 Then Exit Sub
        Select Case e.ColumnIndex
            Case SpalteLandkarteFarbe.Index
                If TypeOf dgvLandkarteMissionen.Rows(e.RowIndex).Cells(e.ColumnIndex) Is DataGridViewTextBoxCell Then
                    Dim btn As DataGridViewTextBoxCell = dgvLandkarteMissionen.Rows(e.RowIndex).Cells(e.ColumnIndex)
                    ColorDialog1.Color = btn.Style.BackColor
                    If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                        ' dgvLandkarteMissionen.Rows(btn.RowIndex).Tag = ""
                        btn.Style.BackColor = ColorDialog1.Color
                        btn.Style.ForeColor = ColorDialog1.Color
                        btn.Style.SelectionBackColor = ColorDialog1.Color
                        btn.Style.SelectionForeColor = ColorDialog1.Color
                    End If
                End If
            Case SpalteLandkarteBild.Index
                If e.Button = Windows.Forms.MouseButtons.Middle Then
                    Dim ZellText As String = dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Value
                    OpenFileDialog1.Title = "choose an Image for this Mission"
                    OpenFileDialog1.Filter = "Picture|*.bmp;*.png|All Files|*.*"
                    OpenFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
                    If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                        Dim HintName As String
                        HintName = LandkartenName + "_Mission_" + e.RowIndex.ToString
                        If LandkartenName.Trim = "" Then
                            HintName = ZellText
                        End If
                        If (Not My.Computer.FileSystem.FileExists(My.Settings.Resourcenpfad + "Landkarten\" + ZellText + ".png")) And (Not ZellText = "") Then
                            HintName = ZellText
                        End If
                        If HintName = "" Then
                            MsgBox("Please choose a campaign directory first!", MsgBoxStyle.Critical, "No valid path")
                            Exit Sub
                        End If
                        My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName, My.Settings.Resourcenpfad + "Landkarten\" + HintName + ".png", True)
                        If My.Computer.FileSystem.FileExists(OpenFileDialog1.FileName.Remove(OpenFileDialog1.FileName.LastIndexOf(".")) + "_Schatten.png") Then
                            My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName.Remove(OpenFileDialog1.FileName.LastIndexOf(".")) + "_Schatten.png", My.Settings.Resourcenpfad + "Landkarten\" + HintName + "_Schatten.png", True)
                        End If
                        dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Value = HintName
                    End If
                End If
            Case SpalteLandkarteKartenname.Index
                If e.Button = Windows.Forms.MouseButtons.Middle Then
                    OpenFileDialog1.Title = "choose a Mission"
                    OpenFileDialog1.Filter = "Mission|*.map"
                    OpenFileDialog1.InitialDirectory = OrdnernameLandkarte
                    If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                        If OpenFileDialog1.FileName.StartsWith(OrdnernameLandkarte) Then
                            'Schön artig eine Karte ausgewählt.
                            dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Value = OpenFileDialog1.FileName.Remove(0, OrdnernameLandkarte.Length + 1).Trim.Replace(".map", "")
                        Else
                            'Was eine Karte im NICHT Kampagnenordner? Du bist ein garstiger User!
                            Dim Kartennnname As String = OpenFileDialog1.FileName
                            Kartennnname = Kartennnname.Trim.Replace(".map", "")
                            Kartennnname = Kartennnname.Remove(0, Kartennnname.LastIndexOf("\") + 1)
                            My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName, OrdnernameLandkarte + "\" + Kartennnname + ".map", True)
                            If My.Computer.FileSystem.FileExists(OpenFileDialog1.FileName.Replace(".map", ".ini")) Then
                                My.Computer.FileSystem.CopyFile(OpenFileDialog1.FileName.Replace(".map", ".ini"), OrdnernameLandkarte + "\" + Kartennnname + ".ini", True)
                            End If
                            dgvLandkarteMissionen(e.ColumnIndex, e.RowIndex).Value = Kartennnname
                        End If
                    End If
                End If
        End Select
    End Sub

    Private Sub SaveIniAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveIniAsToolStripMenuItem.Click
        SpeichernUnterIni()
    End Sub


    Private Sub btnPlayerInformationen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlayerInformationen.Click
        If numSelectedPlayer.Value > Player.Count Then Exit Sub
        'KO's speichern.
        Dim KOS As String = ""
        For I = 0 To KOCheckboxen.Length - 1
            If KOCheckboxen(I).Checked Then
                KOS += KOCheckboxen(I).Name + "|"
            End If
        Next
        Dim P As PlayerInfos = Player.Item(numSelectedPlayer.Value - 1)
        If KOS.Length > 0 Then
            KOS = KOS.Remove(KOS.Length - 1)
            P.KOS1 = KOS
            P.KOS2 = KOS
        End If
        'Bauprioritäten
        If cbAutoBau.Checked Then
            P.KI.Air = cbAutoBauLuft.SelectedIndex
            P.KI.Land = cbAutoBauLand.SelectedIndex
            P.KI.Sea = cbAutoBauSee.SelectedIndex
            P.KI.Direct = cbAutoBauDirekt.SelectedIndex()
            P.KI.Infantrie = cbAutoBauInfantrie.SelectedIndex
            P.KI.Indirect = cbAutoBauIndirekt.SelectedIndex
            P.KI.Transport = cbAutoBauTransport.SelectedIndex
            P.KI.Ausgabefonds = numSavingFonds.Value
            P.KI.DurchschnittlicheTruppenKosten = numBaufonds.Value
            P.KI.AutoGenerated = False
        Else
            P.KI.AutoGenerated = True
        End If


        Player(numSelectedPlayer.Value - 1) = P
    End Sub

    Private Sub numSelectedPlayer_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles numSelectedPlayer.ValueChanged
        If numSelectedPlayer.Value <= Player.Count Then
            Dim P As PlayerInfos = Player.Item(numSelectedPlayer.Value - 1)
            cbAutoBauLuft.SelectedIndex = P.KI.Air
            cbAutoBauLand.SelectedIndex = P.KI.Land
            cbAutoBauSee.SelectedIndex = P.KI.Sea
            cbAutoBauDirekt.SelectedIndex = P.KI.Direct
            cbAutoBauInfantrie.SelectedIndex = P.KI.Infantrie
            cbAutoBauIndirekt.SelectedIndex = P.KI.Indirect
            cbAutoBauTransport.SelectedIndex = P.KI.Transport
            numSavingFonds.Value = P.KI.Ausgabefonds
            numBaufonds.Value = P.KI.DurchschnittlicheTruppenKosten
        End If
    End Sub

    Private Sub cmbIniGameModus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbIniGameModus.SelectedIndexChanged
        Select Case cmbIniGameModus.SelectedIndex - 1
            Case CommanderWarsGameModi.AdvanceWars
                For Each cb In _cmbBauliste
                    cb.SelectedIndex = Baulisten.AW
                Next
            Case CommanderWarsGameModi.AdvanceWars2
                For Each cb In _cmbBauliste
                    cb.SelectedIndex = Baulisten.AW2
                Next
            Case CommanderWarsGameModi.AdvanceWarsDS
                For Each cb In _cmbBauliste
                    cb.SelectedIndex = Baulisten.AWDS
                Next
            Case CommanderWarsGameModi.CommanderWars
                For Each cb In _cmbBauliste
                    cb.SelectedIndex = Baulisten.CoW
                Next
            Case CommanderWarsGameModi.AdvanceWarsDC
                For Each cb In _cmbBauliste
                    cb.SelectedIndex = Baulisten.AWDC
                Next
            Case CommanderWarsGameModi.CommanderWars2
                For Each cb In _cmbBauliste
                    cb.SelectedIndex = Baulisten.CoW2
                Next
            Case Else
        End Select
    End Sub

    Private Sub SaveCustomCOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveCustomCOToolStripMenuItem.Click
        SaveCustomCO()
    End Sub

    Private Sub dgvTagPowers_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvTagPowers.CellEndEdit
        If e.ColumnIndex = dgvCCustomCOCOSynergieID.Index Then
            Dim DDM As DataGridViewComboBoxCell = dgvTagPowers.Rows(e.RowIndex).Cells(dgvCCustomCOCOID1.Index)
            DDM.Items.Clear()
            DDM.Items.Add(txtCustomCOID.Text)
            DDM.Items.Add(dgvTagPowers.Rows(e.RowIndex).Cells(dgvCCustomCOCOSynergieID.Index).Value)
        ElseIf e.ColumnIndex = dgvCCustomCOSynergie.Index Then
            Dim V As String = dgvTagPowers.Rows(e.RowIndex).Cells(dgvCCustomCOSynergie.Index).Value
            If Not IsNumeric(V) Then
                dgvTagPowers.Rows(e.RowIndex).Cells(dgvCCustomCOSynergie.Index).Value = 0
            End If
        End If
    End Sub

    Private Sub dgvTagPowers_RowsAdded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowsAddedEventArgs) Handles dgvTagPowers.RowsAdded
        If dgvTagPowers.RowCount > 1 Then
            If e.RowCount = 1 Then
                Dim DDM As DataGridViewComboBoxCell = dgvTagPowers.Rows(e.RowIndex - 1).Cells(dgvCCustomCOCOSynergieID.Index)
                DDM.Items.Clear()
                DDM.Items.AddRange(KOÜbersetzt)
                DDM.Value = DDM.Items(1)
                Dim DDM1 As DataGridViewComboBoxCell = dgvTagPowers.Rows(e.RowIndex - 1).Cells(dgvCCustomCOCOID1.Index)
                DDM1.Items.Clear()
                DDM1.Items.Add(txtCustomCOID.Text)
                DDM1.Items.Add(DDM.Value)
                Dim DDT As DataGridViewTextBoxCell = dgvTagPowers.Rows(e.RowIndex - 1).Cells(dgvCCustomCOTagPowerName.Index)
                DDT.Value = "Tag Power"
                DDT = dgvTagPowers.Rows(e.RowIndex - 1).Cells(dgvCCustomCOSynergie.Index)
                DDT.Value = 0
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCustomCOImage.Click
        If txtCustomCOID.Text.Trim = "" Then
            MsgBox("Please enter a valid name for this CO!", MsgBoxStyle.Critical, "Error")
            Exit Sub
        End If
        ofdMusik.Filter = "Pictures|*.bmp;*.png|All Files|*.*"
        ofdMusik.Title = "Select Sprite"
        ofdMusik.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
        If ofdMusik.ShowDialog = Windows.Forms.DialogResult.OK Then
            'OK, dann also das Bild kopieren!
            My.Computer.FileSystem.CopyFile(ofdMusik.FileName, My.Settings.Resourcenpfad + "!Custom\CO\CO Sprite\" + txtCustomCOID.Text + ".png")
            btnCustomCOImage.BackColor = Color.Lime
        End If
    End Sub

    Private Sub btnCustomCO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCustomCO.Click
        SavePower()
    End Sub

    Private Sub btnCustomCOMusic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCustomCOMusic.Click
        If txtCustomCOID.Text.Trim = "" Then
            MsgBox("Please enter a valid name for this CO!", MsgBoxStyle.Critical, "Error")
            Exit Sub
        End If
        ofdMusik.Filter = "Music|*.mp3|All Files|*.*"
        ofdMusik.Title = "Select a Music"
        ofdMusik.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)
        If ofdMusik.ShowDialog = Windows.Forms.DialogResult.OK Then
            'OK, dann also das Bild kopieren!
            My.Computer.FileSystem.CopyFile(ofdMusik.FileName, My.Settings.Resourcenpfad + "!Custom\CO\CO Music\" + txtCustomCOID.Text + ".mp3")
            btnCustomCOImage.BackColor = Color.Lime
        End If
    End Sub

    Private Sub cbCustomCOPower_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCustomCOPower.SelectedIndexChanged
        LoadCustomCOPower()
    End Sub

    Private Sub cbOffenceTable_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbOffenceTable.SelectedIndexChanged
        Select Case cbOffenceTable.SelectedIndex
            Case 0
                nudOffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable1, "Offence Boost for all Troops")
                nudOffenceTable2.Visible = False
                nudOffenceTable3.Visible = False
                nudOffenceTable4.Visible = False
            Case 1
                nudOffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable1, "Offence Boost for all Sea Troops")
                nudOffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable2, "Offence Boost for all Air Troops")
                nudOffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable3, "Offence Boost for all Ground Troops")
                nudOffenceTable4.Visible = False
            Case 2
                nudOffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable1, "Offence Boost for all Indirect Troops")
                nudOffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable2, "Offence Boost for all other Troops")
                nudOffenceTable3.Visible = False
                nudOffenceTable4.Visible = False
            Case 3
                nudOffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable1, "Offence Boost for all Tanks")
                nudOffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable2, "Offence Boost for all Infantries")
                nudOffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable3, "Offence Boost for all other Troops")
                nudOffenceTable4.Visible = False
            Case 4
                nudOffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable1, "Offence Boost for all Copters")
                nudOffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable2, "Offence Boost for all Infantries")
                nudOffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable3, "Offence Boost for all Air Troops except Copters")
                nudOffenceTable4.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable4, "Offence Boost for all other Troops.")
            Case 5
                nudOffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable1, "Offence Boost for all Sea and Air Troops")
                nudOffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable2, "Offence Boost for all Infantries")
                nudOffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudOffenceTable3, "Offence Boost for all other Troops")
                nudOffenceTable4.Visible = False
            Case Else
                cbOffenceTable.SelectedIndex = 0
                nudOffenceTable1.Visible = False
                ToolTip1.SetToolTip(nudOffenceTable1, "Offence Boost for all Troops")
                nudOffenceTable2.Visible = False
                nudOffenceTable3.Visible = False
                nudOffenceTable4.Visible = False
        End Select
    End Sub

    Private Sub cbDeffenceTable_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbDeffenceTable.SelectedIndexChanged
        Select Case cbDeffenceTable.SelectedIndex
            Case 0
                nudDeffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable1, "Deffence Boost for all Troops")
                nudDeffenceTable2.Visible = False
                nudDeffenceTable3.Visible = False
                nudDeffenceTable4.Visible = False
            Case 1
                nudDeffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable1, "Deffence Boost for all Sea Troops")
                nudDeffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable2, "Deffence Boost for all Air Troops")
                nudDeffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable3, "Deffence Boost for all Ground Troops")
                nudDeffenceTable4.Visible = False
            Case 2
                nudDeffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable1, "Deffence Boost for all Indirect Troops")
                nudDeffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable2, "Deffence Boost for all other Troops")
                nudDeffenceTable3.Visible = False
                nudDeffenceTable4.Visible = False
            Case 3
                nudDeffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable1, "Deffence Boost for all Tanks")
                nudDeffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable2, "Deffence Boost for all Infantries")
                nudDeffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable3, "Deffence Boost for all other Troops")
                nudDeffenceTable4.Visible = False
            Case 4
                nudDeffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable1, "Deffence Boost for all Copters")
                nudDeffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable2, "Deffence Boost for all Infantries")
                nudDeffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable3, "Deffence Boost for all Air Troops except Copters")
                nudDeffenceTable4.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable4, "Deffence Boost for all other Troops.")
            Case 5
                nudDeffenceTable1.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable1, "Deffence Boost for all Sea and Air Troops")
                nudDeffenceTable2.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable2, "Deffence Boost for all Infantries")
                nudDeffenceTable3.Visible = True
                ToolTip1.SetToolTip(nudDeffenceTable3, "Deffence Boost for all other Troops")
                nudDeffenceTable4.Visible = False
            Case Else
                cbDeffenceTable.SelectedIndex = 0
                nudDeffenceTable1.Visible = False
                ToolTip1.SetToolTip(nudDeffenceTable1, "Deffence Boost for all Troops")
                nudDeffenceTable2.Visible = False
                nudDeffenceTable3.Visible = False
                nudDeffenceTable4.Visible = False
        End Select
    End Sub

    Private Sub cbMovingBoostTable_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbMovingBoostTable.SelectedIndexChanged
        Select Case cbMovingBoostTable.SelectedIndex
            Case 0
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Troops")
            Case 1
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Direct and Indirect Units")
            Case 2
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Hovercrafts")
            Case 3
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Infantries")
            Case 4
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Sea Troops")
            Case 5
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Transport Troops")
            Case 6
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Tanks")
            Case 7
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Directs")
            Case Else
                ToolTip1.SetToolTip(nudMovingBoostTable, "All Troops")
        End Select
    End Sub


    Private Sub btnNewCOEffect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewCOEffect.Click
        If CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript Is Nothing Then
            CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript = New KOCustom.Power.PowerScript()
        End If
        CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects.Add(KOCustom.Power.PowerScript.GetEffect(cbCustomCOScript.SelectedItem, Nothing, Nothing, Nothing, Nothing, Nothing))
        COScriptEffektAktualisieren()
    End Sub

    Private Sub cbCustomCOScript_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCustomCOScript.SelectedIndexChanged
        If lbCustomEvents.SelectedIndex >= 0 Then
            If lbCustomEvents.Items(0) <> "Effects" Then
                If CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects(lbCustomEvents.SelectedIndex) IsNot Nothing Then
                    If CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects(lbCustomEvents.SelectedIndex).ToString.Split(":")(0) = cbCustomCOScript.SelectedItem.ToString Then
                        'Wenn es die gleiche Bedingung ist, dann laden wir die Daten aus dem Array, ansonsten halt die Standardbedingungen.
                        AktuellerCOEffekt = CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects(lbCustomEvents.SelectedIndex).Clone
                    Else
                        AktuellerCOEffekt = KOCustom.Power.PowerScript.GetEffect(cbCustomCOScript.SelectedItem.ToString, Nothing, Nothing, Nothing, Nothing, Nothing)
                    End If
                Else
                    AktuellerCOEffekt = KOCustom.Power.PowerScript.GetEffect(cbCustomCOScript.SelectedItem.ToString, Nothing, Nothing, Nothing, Nothing, Nothing)
                End If

                showCustomCOEffect()
            End If
        End If
    End Sub

    Private Sub btnRemoveCOEffect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveCOEffect.Click
        deleteCustomCOEffect(lbCustomEvents.SelectedIndex)
        lbCustomEvents.Items.Clear()
        If CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects.Count > 0 Then
            For Each Effect In CustomCOPowers(cbCustomCOPower.SelectedIndex).ThisPowerScript.Effects
                lbCustomEvents.Items.Add(Effect.ToString.Split(":")(0))
            Next
        Else
            lbCustomEvents.Items.Add("Effects")
        End If
    End Sub

    Private Sub btnSaveCOEffect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveCOEffect.Click
        SaveCustomCOEffect()
    End Sub

    Private Sub lbCustomEvents_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbCustomEvents.SelectedIndexChanged
        showCustomCOEffect()
    End Sub

    Private Sub OpenCustomCOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenCustomCOToolStripMenuItem.Click
        OpenCustomCO()
    End Sub
End Class
